colour.continuous.AbstractContinuousFunction#

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

Bases: ABC, MixinCallback

Define the base class for an 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 (str | None) – Continuous function name.

Attributes

Methods

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

name (str | None)

Return type:

None

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:

str

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:

Type[DTypeFloat]

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:

numpy.ndarray

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:

numpy.ndarray

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:

Type[ProtocolInterpolator]

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:

dict

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:

Type[ProtocolExtrapolator]

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:

dict

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:

Callable

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:

str

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:

str

abstractmethod __hash__() int[source]#

Compute the hash of the abstract continuous function.

Returns:

Object hash.

Return type:

int

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:

numpy.ndarray

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.

Parameters:
  • x (TypeAliasForwardRef('ArrayLike') | slice) – Independent domain variable \(x\).

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

Return type:

None

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.

Parameters:

x (TypeAliasForwardRef('ArrayLike') | slice) – Independent domain variable \(x\).

Returns:

Whether \(x\) domain value is contained.

Return type:

bool

__iter__() Generator[source]#

Return a generator for the abstract continuous function.

Yields:

Generator – Abstract continuous function generator.

Return type:

Generator

__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:

int

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.

Parameters:

other (object) – Object to determine for equality with the abstract continuous function.

Returns:

Whether the specified object is equal to the abstract continuous function.

Return type:

bool

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.

Parameters:

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

Returns:

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

Return type:

bool

__add__(a: ArrayLike | Self) Self[source]#

Implement support for addition.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to add to the continuous function.

Returns:

Abstract continuous function with the specified variable added.

Return type:

colour.continuous.AbstractContinuousFunction

__iadd__(a: ArrayLike | Self) Self[source]#

Implement support for in-place addition.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to add in-place to the abstract continuous function.

Returns:

Abstract continuous function with in-place addition applied.

Return type:

colour.continuous.AbstractContinuousFunction

__sub__(a: ArrayLike | Self) Self[source]#

Implement support for subtraction.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to subtract from the continuous function.

Returns:

Abstract continuous function with the specified variable subtracted.

Return type:

colour.continuous.AbstractContinuousFunction

__isub__(a: ArrayLike | Self) Self[source]#

Implement support for in-place subtraction.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to subtract in-place from the abstract continuous function.

Returns:

Abstract continuous function with in-place subtraction applied.

Return type:

colour.continuous.AbstractContinuousFunction

__mul__(a: ArrayLike | Self) Self[source]#

Implement support for multiplication.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to multiply the continuous function by.

Returns:

Abstract continuous function with the specified variable multiplied.

Return type:

colour.continuous.AbstractContinuousFunction

__imul__(a: ArrayLike | Self) Self[source]#

Implement support for in-place multiplication.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to multiply in-place by the abstract continuous function.

Returns:

Abstract continuous function with in-place multiplication applied.

Return type:

colour.continuous.AbstractContinuousFunction

__div__(a: ArrayLike | Self) Self[source]#

Implement support for division.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to divide the continuous function by.

Returns:

Abstract continuous function with the specified variable divided.

Return type:

colour.continuous.AbstractContinuousFunction

__idiv__(a: ArrayLike | Self) Self[source]#

Implement support for in-place division.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to divide in-place by the abstract continuous function.

Returns:

Abstract continuous function with in-place division applied.

Return type:

colour.continuous.AbstractContinuousFunction

__itruediv__(a: ArrayLike | Self) Self#

Implement support for in-place division.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to divide in-place by the abstract continuous function.

Returns:

Abstract continuous function with in-place division applied.

Return type:

colour.continuous.AbstractContinuousFunction

__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 the continuous function by.

Returns:

Abstract continuous function with the specified variable divided.

Return type:

colour.continuous.AbstractContinuousFunction

__pow__(a: ArrayLike | Self) Self[source]#

Implement support for exponentiation.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to raise the continuous function to the power of.

Returns:

Abstract continuous function with the specified variable exponentiated.

Return type:

colour.continuous.AbstractContinuousFunction

__ipow__(a: ArrayLike | Self) Self[source]#

Implement support for in-place exponentiation.

Parameters:

a (ArrayLike | Self) – Variable \(a\) to raise in-place the abstract continuous function to the power of.

Returns:

Abstract continuous function with in-place exponentiation applied.

Return type:

colour.continuous.AbstractContinuousFunction

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:
  • a (ArrayLike | Self) – Operand \(a\). Can be a numeric value, array-like object, or another continuous function instance.

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

  • in_place (bool) – Operation happens in place.

Returns:

Abstract continuous function.

Return type:

colour.continuous.AbstractContinuousFunction

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:
  • method (Literal['Constant', 'Interpolation'] | 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:

colour.continuous.AbstractContinuousFunction

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:

numpy.ndarray

is_uniform() bool[source]#

Return whether the independent domain variable \(x\) is uniform.

Returns:

Whether the independent domain variable \(x\) is uniform.

Return type:

bool

copy() Self[source]#

Return a copy of the sub-class instance.

Returns:

Copy of the abstract continuous function.

Return type:

colour.continuous.AbstractContinuousFunction