colour.continuous.AbstractContinuousFunction#
- class colour.continuous.AbstractContinuousFunction(name: str | None = None)[source]#
Bases:
ABC,MixinCallbackDefine the base class for an abstract continuous function.
This is an
ABCMetaabstract 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.domainattribute, corresponds with the function dependent and already known range stored in thecolour.continuous.AbstractContinuousFunction.rangeproperty.- Parameters:
name (str | None) – Continuous function name.
Attributes
Methods
- property name: str#
Getter and setter 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 for the abstract continuous function dtype.
This property must be reimplemented by sub-classes.
- Parameters:
value – Value to set the abstract continuous function dtype with.
- Returns:
Abstract continuous function dtype.
- Return type:
- abstract property domain: NDArrayFloat#
Getter and setter for the abstract continuous function’s independent domain variable \(x\).
This property 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 for the abstract continuous function’s range variable \(y\).
This property must be reimplemented by sub-classes.
- Parameters:
value – Value to set the abstract continuous function’s range variable \(y\) with.
- Returns:
Abstract continuous function’s range variable \(y\).
- Return type:
- abstract property interpolator: Type[ProtocolInterpolator]#
Getter and setter for the abstract continuous function interpolator type.
This property 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:
- abstract property interpolator_kwargs: dict#
Getter and setter for the interpolator instantiation time arguments.
This property 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 for the abstract continuous function extrapolator type.
This property 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:
- abstract property extrapolator_kwargs: dict#
Getter and setter for the abstract continuous function extrapolator instantiation time arguments.
This property 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 for the abstract continuous function callable.
This property must be reimplemented by sub-classes.
- Returns:
Abstract continuous function callable.
- Return type:
- abstractmethod __str__() str[source]#
Return a formatted string representation of the abstract continuous function.
This method must be reimplemented by sub-classes.
- Returns:
Formatted string representation.
- Return type:
- abstractmethod __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:
- abstractmethod __hash__() int[source]#
Compute the hash of the abstract continuous function.
- Returns:
Object hash.
- Return type:
- abstractmethod __getitem__(x: TypeAliasForwardRef('ArrayLike') | slice) NDArrayFloat[source]#
Return the corresponding range variable \(y\) for the specified independent domain variable \(x\).
This abstract method must be reimplemented by sub-classes.
- Parameters:
x (TypeAliasForwardRef('ArrayLike') | slice) – Independent domain variable \(x\).
- Returns:
Variable \(y\) range value.
- Return type:
- abstractmethod __setitem__(x: TypeAliasForwardRef('ArrayLike') | slice, y: ArrayLike) None[source]#
Set the corresponding range variable \(y\) for the specified independent domain variable \(x\).
This abstract method must be reimplemented by sub-classes.
- abstractmethod __contains__(x: TypeAliasForwardRef('ArrayLike') | slice) bool[source]#
Determine whether the abstract continuous function contains the specified independent domain variable \(x\).
This abstract method 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 number of elements in the abstract continuous function’s independent domain variable \(x\).
- Returns:
Number of elements in the independent domain variable \(x\).
- Return type:
- abstractmethod __eq__(other: object) bool[source]#
Determine whether the abstract continuous function equals the specified object.
This abstract method must be reimplemented by sub-classes.
- abstractmethod __ne__(other: object) bool[source]#
Determine whether the abstract continuous function is not equal to the specified object.
This method must be reimplemented by sub-classes.
- __add__(a: ArrayLike | Self) Self[source]#
Implement support for addition.
- __iadd__(a: ArrayLike | Self) Self[source]#
Implement support for in-place addition.
- __sub__(a: ArrayLike | Self) Self[source]#
Implement support for subtraction.
- __isub__(a: ArrayLike | Self) Self[source]#
Implement support for in-place subtraction.
- __mul__(a: ArrayLike | Self) Self[source]#
Implement support for multiplication.
- __imul__(a: ArrayLike | Self) Self[source]#
Implement support for in-place multiplication.
- __div__(a: ArrayLike | Self) Self[source]#
Implement support for division.
- __idiv__(a: ArrayLike | Self) Self[source]#
Implement support for in-place division.
- __itruediv__(a: ArrayLike | Self) Self#
Implement support for in-place division.
- __weakref__#
list of weak references to the object
- __truediv__(a: ArrayLike | Self) Self#
Implement support for division.
- __pow__(a: ArrayLike | Self) Self[source]#
Implement support for exponentiation.
- __ipow__(a: ArrayLike | Self) Self[source]#
Implement support for in-place exponentiation.
- abstractmethod arithmetical_operation(a: ArrayLike | Self, operation: Literal['+', '-', '*', '/', '**'], in_place: bool = False) Self[source]#
Perform the specified arithmetical operation with operand \(a\), either on a copy or in-place.
This method must be reimplemented by sub-classes.
- Parameters:
- Returns:
Abstract continuous function.
- Return type:
- abstractmethod fill_nan(method: Literal['Constant', 'Interpolation'] | str = 'Interpolation', default: Real = 0) Self[source]#
Fill NaNs in independent domain variable \(x\) and corresponding range variable \(y\) using the specified method.
This abstract method must be reimplemented by sub-classes.
- Parameters:
- Returns:
NaNs filled abstract continuous function.
- Return type:
- domain_distance(a: ArrayLike) NDArrayFloat[source]#
Return the Euclidean distance between specified array and the closest element of the independent domain \(x\).
- Parameters:
a (ArrayLike) – Variable \(a\) to compute the Euclidean distance with the independent domain variable \(x\).
- Returns:
Euclidean distance between independent domain variable \(x\) and specified variable \(a\).
- Return type:
- is_uniform() bool[source]#
Return whether the independent domain variable \(x\) is uniform.
- Returns:
Whether the independent domain variable \(x\) is uniform.
- Return type: