colour.continuous.AbstractContinuousFunction#
- class colour.continuous.AbstractContinuousFunction(name: str | None = None)[source]#
Bases:
ABC
,MixinCallback
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 (str | None) – 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: Type[DTypeFloat]#
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[DTypeFloat]
- abstract property domain: NDArrayFloat#
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: NDArrayFloat#
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[ProtocolInterpolator]#
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[ProtocolInterpolator]
- 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[ProtocolExtrapolator]#
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[ProtocolExtrapolator]
- 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: ArrayLike | slice) NDArrayFloat [source]#
Return the corresponding range variable \(y\) for independent domain variable \(x\), must be reimplemented by sub-classes.
- Parameters:
x (ArrayLike | slice) – Independent domain variable \(x\).
- Returns:
Variable \(y\) range value.
- Return type:
- abstract __setitem__(x: ArrayLike | slice, y: ArrayLike)[source]#
Set the corresponding range variable \(y\) for independent domain variable \(x\), must be reimplemented by sub-classes.
- Parameters:
x (ArrayLike | slice) – Independent domain variable \(x\).
y (ArrayLike) – Corresponding range variable \(y\).
- abstract __contains__(x: ArrayLike | slice) bool [source]#
Return whether the abstract continuous function contains given independent domain variable \(x\), must be reimplemented by sub-classes.
- __iter__() Generator [source]#
Return a generator for the abstract continuous function.
- Yields:
Generator – Abstract continuous function generator.
- Return type:
- __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: ArrayLike | Self) Self [source]#
Implement support for addition.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to add.
- Returns:
Variable added abstract continuous function.
- Return type:
- __iadd__(a: ArrayLike | Self) Self [source]#
Implement support for in-place addition.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to add in-place.
- Returns:
In-place variable added abstract continuous function.
- Return type:
- __sub__(a: ArrayLike | Self) Self [source]#
Implement support for subtraction.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to subtract.
- Returns:
Variable subtracted abstract continuous function.
- Return type:
- __isub__(a: ArrayLike | Self) Self [source]#
Implement support for in-place subtraction.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to subtract in-place.
- Returns:
In-place variable subtracted abstract continuous function.
- Return type:
- __mul__(a: ArrayLike | Self) Self [source]#
Implement support for multiplication.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to multiply by.
- Returns:
Variable multiplied abstract continuous function.
- Return type:
- __imul__(a: ArrayLike | Self) Self [source]#
Implement support for in-place multiplication.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to multiply by in-place.
- Returns:
In-place variable multiplied abstract continuous function.
- Return type:
- __div__(a: ArrayLike | Self) Self [source]#
Implement support for division.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to divide by.
- Returns:
Variable divided abstract continuous function.
- Return type:
- __idiv__(a: ArrayLike | Self) Self [source]#
Implement support for in-place division.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to divide by in-place.
- Returns:
In-place variable divided abstract continuous function.
- Return type:
- __itruediv__(a: ArrayLike | Self) Self #
Implement support for in-place division.
- Parameters:
a (ArrayLike | Self) – 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
- __truediv__(a: ArrayLike | Self) Self #
Implement support for division.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to divide by.
- Returns:
Variable divided abstract continuous function.
- Return type:
- __pow__(a: ArrayLike | Self) Self [source]#
Implement support for exponentiation.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to exponentiate by.
- Returns:
Variable exponentiated abstract continuous function.
- Return type:
- __ipow__(a: ArrayLike | Self) Self [source]#
Implement support for in-place exponentiation.
- Parameters:
a (ArrayLike | Self) – Variable \(a\) to exponentiate by in-place.
- Returns:
In-place variable exponentiated abstract continuous function.
- Return type:
- abstract arithmetical_operation(a: ArrayLike | Self, operation: Literal['+', '-', '*', '/', '**'], in_place: bool = False) Self [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:
- Returns:
Abstract continuous function.
- Return type:
- abstract fill_nan(method: Literal['Interpolation', 'Constant'] | str = 'Interpolation', default: Real = 0) Self [source]#
Fill NaNs in independent domain variable \(x\) and corresponding range variable \(y\) using given method, must be reimplemented by sub-classes.
- Parameters:
method (Literal['Interpolation', 'Constant'] | str) – Interpolation method linearly interpolates through the NaNs, Constant method replaces NaNs with
default
.default (Real) – Value to use with the Constant method.
- Returns:
NaNs filled abstract continuous function.
- Return type:
- domain_distance(a: ArrayLike) NDArrayFloat [source]#
Return the euclidean distance between given array and independent domain \(x\) closest element.
- Parameters:
a (ArrayLike) – 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: