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

numpy.ndarray

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:

numpy.ndarray

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:

dict

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:

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:

int

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:

numpy.ndarray

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.

Parameters:

x (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 abstract continuous function independent domain \(x\) variable elements count.

Returns:

Independent domain variable \(x\) elements count.

Return type:

int

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: ArrayLike | Self) Self[source]#

Implement support for addition.

Parameters:

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

Returns:

Variable added abstract continuous function.

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.

Returns:

In-place variable added abstract continuous function.

Return type:

colour.continuous.AbstractContinuousFunction

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

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.

Returns:

In-place variable subtracted abstract continuous function.

Return type:

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

__weakref__#

list of weak references to the object (if defined)

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

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

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

colour.continuous.AbstractContinuousFunction

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:
  • a (ArrayLike | Self) – Operand \(a\).

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

  • in_place (bool) – Operation happens in place.

Returns:

Abstract continuous function.

Return type:

colour.continuous.AbstractContinuousFunction

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:

colour.continuous.AbstractContinuousFunction

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:

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() Self[source]#

Return a copy of the sub-class instance.

Returns:

Abstract continuous function copy.

Return type:

colour.continuous.AbstractContinuousFunction