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 thecolour.continuous.AbstractContinuousFunction.domain
attribute corresponds with the function dependent and already known range stored in thecolour.continuous.AbstractContinuousFunction.range
property.- Parameters
name (Optional[str]) – Continuous function name.
Attributes
Methods
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- abstract __hash__() int [source]¶
Return the abstract continuous function hash.
- Returns
Object hash.
- Return type
- 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
- 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.
- __len__() int [source]¶
Return the abstract continuous function independent domain \(x\) variable elements count.
- Returns
Independent domain variable \(x\) elements count.
- Return type
- abstract __eq__(other: Any) bool [source]¶
Return whether the abstract continuous function is equal to given other object, must be reimplemented by sub-classes.
- 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.
- __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
- __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
- __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
- __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
- __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
- __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
- __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
- __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
- __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
- __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
- __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
- __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
- 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
- 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
- Returns
NaNs filled abstract continuous function.
- Return type
- 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
- is_uniform() bool [source]¶
Return if independent domain variable \(x\) is uniform.
- Returns
Is independent domain variable \(x\) uniform.
- Return type
- copy() colour.continuous.abstract.AbstractContinuousFunction [source]¶
Return a copy of the sub-class instance.
- Returns
Abstract continuous function copy.
- Return type