colour.continuous.AbstractContinuousFunction

class colour.continuous.AbstractContinuousFunction(name=None)[source]

Bases: abc.ABC

Defines 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 \(x \in\mathbb{R}\) variable returns a corresponding range \(y \in\mathbb{R}\) variable. 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 attribute.

Parameters

name (unicode, optional) – Continuous function name.

Attributes

Methods

__init__(name=None)[source]
property name

Getter and setter property for the abstract continuous function name.

Parameters

value (unicode) – Value to set the abstract continuous function name with.

Returns

Abstract continuous function name.

Return type

unicode

abstract property domain

Getter and setter property for the abstract continuous function independent domain \(x\) variable, must be reimplemented by sub-classes.

Parameters

value (array_like) – Value to set the abstract continuous function independent domain \(x\) variable with.

Returns

Abstract continuous function independent domain \(x\) variable.

Return type

ndarray

abstract property range

Getter and setter property for the abstract continuous function corresponding range \(y\) variable, must be reimplemented by sub-classes.

Parameters

value (array_like) – Value to set the abstract continuous function corresponding range \(y\) variable with.

Returns

Abstract continuous function corresponding range \(y\) variable.

Return type

ndarray

abstract property interpolator

Getter and setter property for the abstract continuous function interpolator type, must be reimplemented by sub-classes.

Parameters

value (type) – Value to set the abstract continuous function interpolator type with.

Returns

Abstract continuous function interpolator type.

Return type

type

abstract property interpolator_kwargs

Getter and setter property for the abstract continuous function interpolator instantiation time arguments, must be reimplemented by sub-classes.

Parameters

value (dict) – 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

Getter and setter property for the abstract continuous function extrapolator type, must be reimplemented by sub-classes.

Parameters

value (type) – Value to set the abstract continuous function extrapolator type with.

Returns

Abstract continuous function extrapolator type.

Return type

type

abstract property extrapolator_kwargs

Getter and setter property for the abstract continuous function extrapolator instantiation time arguments, must be reimplemented by sub-classes.

Parameters

value (dict) – 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

Getter and setter property for the abstract continuous function callable, must be reimplemented by sub-classes.

Parameters

value (object) – Attribute value.

Returns

Abstract continuous function callable.

Return type

callable

abstract __str__()[source]

Returns a formatted string representation of the abstract continuous function, must be reimplemented by sub-classes.

Returns

Formatted string representation.

Return type

unicode

abstract __repr__()[source]

Returns an evaluable string representation of the abstract continuous function, must be reimplemented by sub-classes.

Returns

Evaluable string representation.

Return type

unicode

abstract __hash__()[source]

Returns the abstract continuous function hash.

Returns

Object hash.

Return type

int

abstract __getitem__(x)[source]

Returns the corresponding range \(y\) variable for independent domain \(x\) variable, must be reimplemented by sub-classes.

Parameters

x (numeric, array_like or slice) – Independent domain \(x\) variable.

Returns

math:y range value.

Return type

numeric or ndarray

abstract __setitem__(x, y)[source]

Sets the corresponding range \(y\) variable for independent domain \(x\) variable, must be reimplemented by sub-classes.

Parameters
  • x (numeric, array_like or slice) – Independent domain \(x\) variable.

  • y (numeric or ndarray) – Corresponding range \(y\) variable.

abstract __contains__(x)[source]

Returns whether the abstract continuous function contains given independent domain \(x\) variable, must be reimplemented by sub-classes.

Parameters

x (numeric, array_like or slice) – Independent domain \(x\) variable.

Returns

Is \(x\) domain value contained.

Return type

bool

__len__()[source]

Returns the abstract continuous function independent domain \(x\) variable elements count.

Returns

Independent domain \(x\) variable elements count.

Return type

int

abstract __eq__(other)[source]

Returns whether the abstract continuous function is equal to given other object, must be reimplemented by sub-classes.

Parameters

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

Returns

Is given object equal to the abstract continuous function.

Return type

bool

abstract __ne__(other)[source]

Returns whether the abstract continuous function is not equal to given other object, must be reimplemented by sub-classes.

Parameters

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

Returns

Is given object not equal to the abstract continuous function.

Return type

bool

__add__(a)[source]

Implements support for addition.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to add.

Returns

Variable added abstract continuous function.

Return type

AbstractContinuousFunction

__iadd__(a)[source]

Implements support for in-place addition.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to add in-place.

Returns

In-place variable added abstract continuous function.

Return type

AbstractContinuousFunction

__sub__(a)[source]

Implements support for subtraction.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to subtract.

Returns

Variable subtracted abstract continuous function.

Return type

AbstractContinuousFunction

__isub__(a)[source]

Implements support for in-place subtraction.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to subtract in-place.

Returns

In-place variable subtracted abstract continuous function.

Return type

AbstractContinuousFunction

__mul__(a)[source]

Implements support for multiplication.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to multiply by.

Returns

Variable multiplied abstract continuous function.

Return type

AbstractContinuousFunction

__imul__(a)[source]

Implements support for in-place multiplication.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to multiply by in-place.

Returns

In-place variable multiplied abstract continuous function.

Return type

AbstractContinuousFunction

__div__(a)[source]

Implements support for division.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to divide by.

Returns

Variable divided abstract continuous function.

Return type

AbstractContinuousFunction

__idiv__(a)[source]

Implements support for in-place division.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to divide by in-place.

Returns

In-place variable divided abstract continuous function.

Return type

AbstractContinuousFunction

__itruediv__(a)

Implements support for in-place division.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to divide by in-place.

Returns

In-place variable divided abstract continuous function.

Return type

AbstractContinuousFunction

__truediv__(a)

Implements support for division.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to divide by.

Returns

Variable divided abstract continuous function.

Return type

AbstractContinuousFunction

__pow__(a)[source]

Implements support for exponentiation.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to exponentiate by.

Returns

Variable exponentiated abstract continuous function.

Return type

AbstractContinuousFunction

__ipow__(a)[source]

Implements support for in-place exponentiation.

Parameters

a (numeric or array_like or AbstractContinuousFunction) – \(a\) variable to exponentiate by in-place.

Returns

In-place variable exponentiated abstract continuous function.

Return type

AbstractContinuousFunction

abstract arithmetical_operation(a, operation, in_place=False)[source]

Performs given arithmetical operation with \(a\) operand, 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

AbstractContinuousFunction

abstract fill_nan(method='Interpolation', default=0)[source]

Fill NaNs in independent domain \(x\) variable and corresponding range \(y\) variable using given method, must be reimplemented by sub-classes.

Parameters
  • method (unicode, optional) – {‘Interpolation’, ‘Constant’}, Interpolation method linearly interpolates through the NaNs, Constant method replaces NaNs with default.

  • default (numeric, optional) – Value to use with the Constant method.

Returns

NaNs filled abstract continuous function.

Return type

AbstractContinuousFunction

__weakref__

list of weak references to the object (if defined)

domain_distance(a)[source]

Returns the euclidean distance between given array and independent domain \(x\) closest element.

Parameters

a (numeric or array_like) – \(a\) variable to compute the euclidean distance with independent domain \(x\) variable.

Returns

Euclidean distance between independent domain \(x\) variable and given \(a\) variable.

Return type

numeric or array_like

is_uniform()[source]

Returns if independent domain \(x\) variable is uniform.

Returns

Is independent domain \(x\) variable uniform.

Return type

bool

copy()[source]

Returns a copy of the sub-class instance.

Returns

Abstract continuous function copy.

Return type

AbstractContinuousFunction