colour.continuous.AbstractContinuousFunction

class colour.continuous.AbstractContinuousFunction(name: Optional[str] = None)[source]

Bases: abc.ABC

Define the base class for abstract continuous function.

This is an ABCMeta abstract class that must be inherited by sub-classes.

The sub-classes are expected to implement the colour.continuous.AbstractContinuousFunction.function() method so that evaluating the function for any independent domain variable \(x \in\mathbb{R}\) returns a corresponding range variable \(y \in\mathbb{R}\). A conventional implementation adopts an interpolating function encapsulated inside an extrapolating function. The resulting function independent domain, stored as discrete values in the colour.continuous.AbstractContinuousFunction.domain attribute corresponds with the function dependent and already known range stored in the colour.continuous.AbstractContinuousFunction.range property.

Parameters

name (Optional[str]) – Continuous function name.

Attributes

Methods

__init__(name: Optional[str] = None)[source]
Parameters

name (Optional[str]) –

property name: str

Getter and setter property for the abstract continuous function name.

Parameters

value – Value to set the abstract continuous function name with.

Returns

Abstract continuous function name.

Return type

str

abstract property dtype

Getter and setter property for the abstract continuous function dtype, must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function dtype with.

Returns

Abstract continuous function dtype.

Return type

Type[DTypeFloating]

abstract property domain: numpy.ndarray

Getter and setter property for the abstract continuous function independent domain variable \(x\), must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function independent domain variable \(x\) with.

Returns

Abstract continuous function independent domain variable \(x\).

Return type

numpy.ndarray

abstract property range: numpy.ndarray

Getter and setter property for the abstract continuous function corresponding range variable \(y\), must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function corresponding range variable \(y\) with.

Returns

Abstract continuous function corresponding range variable \(y\).

Return type

numpy.ndarray

abstract property interpolator: Type[colour.hints.TypeInterpolator]

Getter and setter property for the abstract continuous function interpolator type, must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function interpolator type with.

Returns

Abstract continuous function interpolator type.

Return type

Type[TypeInterpolator]

abstract property interpolator_kwargs: Dict

Getter and setter property for the abstract continuous function interpolator instantiation time arguments, must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function interpolator instantiation time arguments to.

Returns

Abstract continuous function interpolator instantiation time arguments.

Return type

dict

abstract property extrapolator: Type[colour.hints.TypeExtrapolator]

Getter and setter property for the abstract continuous function extrapolator type, must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function extrapolator type with.

Returns

Abstract continuous function extrapolator type.

Return type

Type[TypeExtrapolator]

abstract property extrapolator_kwargs: Dict

Getter and setter property for the abstract continuous function extrapolator instantiation time arguments, must be reimplemented by sub-classes.

Parameters

value – Value to set the abstract continuous function extrapolator instantiation time arguments to.

Returns

Abstract continuous function extrapolator instantiation time arguments.

Return type

dict

abstract property function: Callable

Getter property for the abstract continuous function callable, must be reimplemented by sub-classes.

Returns

Abstract continuous function callable.

Return type

Callable

abstract __str__() str[source]

Return a formatted string representation of the abstract continuous function, must be reimplemented by sub-classes.

Returns

Formatted string representation.

Return type

str

abstract __repr__() str[source]

Return an evaluable string representation of the abstract continuous function, must be reimplemented by sub-classes.

Returns

Evaluable string representation.

Return type

str

abstract __hash__() int[source]

Return the abstract continuous function hash.

Returns

Object hash.

Return type

numpy.integer

abstract __getitem__(x: Union[FloatingOrArrayLike, slice]) FloatingOrNDArray[source]

Return the corresponding range variable \(y\) for independent domain variable \(x\), must be reimplemented by sub-classes.

Parameters

x (Union[FloatingOrArrayLike, slice]) – Independent domain variable \(x\).

Returns

Variable \(y\) range value.

Return type

numpy.floating or numpy.ndarray

abstract __setitem__(x: Union[FloatingOrArrayLike, slice], y: FloatingOrArrayLike)[source]

Set the corresponding range variable \(y\) for independent domain variable \(x\), must be reimplemented by sub-classes.

Parameters
  • x (Union[FloatingOrArrayLike, slice]) – Independent domain variable \(x\).

  • y (FloatingOrArrayLike) – Corresponding range variable \(y\).

abstract __contains__(x: Union[FloatingOrArrayLike, slice]) bool[source]

Return whether the abstract continuous function contains given independent domain variable \(x\), must be reimplemented by sub-classes.

Parameters

x (Union[FloatingOrArrayLike, slice]) – Independent domain variable \(x\).

Returns

Whether \(x\) domain value is contained.

Return type

bool

__len__() int[source]

Return the abstract continuous function independent domain \(x\) variable elements count.

Returns

Independent domain variable \(x\) elements count.

Return type

numpy.integer

abstract __eq__(other: Any) bool[source]

Return whether the abstract continuous function is equal to given other object, must be reimplemented by sub-classes.

Parameters

other (Any) – Object to test whether it is equal to the abstract continuous function.

Returns

Whether given object is equal to the abstract continuous function.

Return type

bool

abstract __ne__(other: Any) bool[source]

Return whether the abstract continuous function is not equal to given other object, must be reimplemented by sub-classes.

Parameters

other (Any) – Object to test whether it is not equal to the abstract continuous function.

Returns

Whether given object is not equal to the abstract continuous function.

Return type

bool

__add__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for addition.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to add.

Returns

Variable added abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__iadd__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for in-place addition.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to add in-place.

Returns

In-place variable added abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__sub__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for subtraction.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to subtract.

Returns

Variable subtracted abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__isub__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for in-place subtraction.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to subtract in-place.

Returns

In-place variable subtracted abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__mul__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for multiplication.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to multiply by.

Returns

Variable multiplied abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__imul__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for in-place multiplication.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to multiply by in-place.

Returns

In-place variable multiplied abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__div__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for division.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to divide by.

Returns

Variable divided abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__idiv__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for in-place division.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to divide by in-place.

Returns

In-place variable divided abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__itruediv__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction

Implement support for in-place division.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to divide by in-place.

Returns

In-place variable divided abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__weakref__

list of weak references to the object (if defined)

__truediv__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction

Implement support for division.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to divide by.

Returns

Variable divided abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__pow__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for exponentiation.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to exponentiate by.

Returns

Variable exponentiated abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

__ipow__(a: Union[FloatingOrArrayLike, AbstractContinuousFunction]) AbstractContinuousFunction[source]

Implement support for in-place exponentiation.

Parameters

a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Variable \(a\) to exponentiate by in-place.

Returns

In-place variable exponentiated abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

abstract arithmetical_operation(a: Union[FloatingOrArrayLike, AbstractContinuousFunction], operation: Literal['+', '-', '*', '/', '**'], in_place: Boolean = False) AbstractContinuousFunction[source]

Perform given arithmetical operation with operand \(a\), the operation can be either performed on a copy or in-place, must be reimplemented by sub-classes.

Parameters
  • a (Union[FloatingOrArrayLike, AbstractContinuousFunction]) – Operand \(a\).

  • operation (Literal[('+', '-', '*', '/', '**')]) – Operation to perform.

  • in_place (Boolean) – Operation happens in place.

Returns

Abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

abstract fill_nan(method: Union[Literal['Constant', 'Interpolation'], str] = 'Interpolation', default: Number = 0) colour.continuous.abstract.AbstractContinuousFunction[source]

Fill NaNs in independent domain variable \(x\) and corresponding range variable \(y\) using given method, must be reimplemented by sub-classes.

Parameters
  • method (Union[Literal['Constant', 'Interpolation'], str]) – Interpolation method linearly interpolates through the NaNs, Constant method replaces NaNs with default.

  • default (Number) – Value to use with the Constant method.

Returns

NaNs filled abstract continuous function.

Return type

colour.continuous.AbstractContinuousFunction

domain_distance(a: FloatingOrArrayLike) FloatingOrNDArray[source]

Return the euclidean distance between given array and independent domain \(x\) closest element.

Parameters

a (FloatingOrArrayLike) – Variable \(a\) to compute the euclidean distance with independent domain variable \(x\).

Returns

Euclidean distance between independent domain variable \(x\) and given variable \(a\).

Return type

numpy.floating or numpy.ndarray

is_uniform() bool[source]

Return if independent domain variable \(x\) is uniform.

Returns

Is independent domain variable \(x\) uniform.

Return type

bool

copy() colour.continuous.abstract.AbstractContinuousFunction[source]

Return a copy of the sub-class instance.

Returns

Abstract continuous function copy.

Return type

colour.continuous.AbstractContinuousFunction