colour.NullInterpolator#

class colour.NullInterpolator(x: ArrayLike, y: ArrayLike, absolute_tolerance: float = TOLERANCE_ABSOLUTE_DEFAULT, relative_tolerance: float = TOLERANCE_RELATIVE_DEFAULT, default: float = np.nan, dtype: Type[DTypeReal] | None = None, *args: Any, **kwargs: Any)[source]#

Bases: object

Perform 1-D function null interpolation, i.e. a call within given tolerances will return existing \(y\) variable values and default if outside tolerances.

Parameters:
  • x (ArrayLike) – Independent \(x\) variable values corresponding with \(y\) variable.

  • y (ArrayLike) – Dependent and already known \(y\) variable values to interpolate.

  • absolute_tolerance (float) – Absolute tolerance.

  • relative_tolerance (float) – Relative tolerance.

  • default (float) – Default value for interpolation outside tolerances.

  • dtype (Type[DTypeReal] | None) – Data type used for internal conversions.

  • args (Any) –

  • kwargs (Any) –

Attributes

Methods

Examples

>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500])
>>> x = np.arange(len(y))
>>> f = NullInterpolator(x, y)
>>> f(0.5)
nan
>>> f(1.0)  
9.3699999...
>>> f = NullInterpolator(x, y, absolute_tolerance=0.01)
>>> f(1.01)  
9.3699999...
__init__(x: ArrayLike, y: ArrayLike, absolute_tolerance: float = TOLERANCE_ABSOLUTE_DEFAULT, relative_tolerance: float = TOLERANCE_RELATIVE_DEFAULT, default: float = np.nan, dtype: Type[DTypeReal] | None = None, *args: Any, **kwargs: Any) None[source]#
Parameters:
  • x (ArrayLike) –

  • y (ArrayLike) –

  • absolute_tolerance (float) –

  • relative_tolerance (float) –

  • default (float) –

  • dtype (Type[DTypeReal] | None) –

  • args (Any) –

  • kwargs (Any) –

Return type:

None

__weakref__#

list of weak references to the object (if defined)

property x: NDArrayFloat#

Getter and setter property for the independent \(x\) variable.

Parameters:

value – Value to set the independent \(x\) variable with.

Returns:

Independent \(x\) variable.

Return type:

numpy.ndarray

property y: NDArrayFloat#

Getter and setter property for the dependent and already known \(y\) variable.

Parameters:

value – Value to set the dependent and already known \(y\) variable with.

Returns:

Dependent and already known \(y\) variable.

Return type:

numpy.ndarray

property relative_tolerance: float#

Getter and setter property for the relative tolerance.

Parameters:

value – Value to set the relative tolerance with.

Returns:

Relative tolerance.

Return type:

float

property absolute_tolerance: float#

Getter and setter property for the absolute tolerance.

Parameters:

value – Value to set the absolute tolerance with.

Returns:

Absolute tolerance.

Return type:

float

property default: float#

Getter and setter property for the default value for call outside tolerances.

Parameters:

value – Value to set the default value with.

Returns:

Default value.

Return type:

float

__call__(x: ArrayLike) NDArrayFloat[source]#

Evaluate the interpolator at given point(s).

Parameters:

x (ArrayLike) – Point(s) to evaluate the interpolant at.

Returns:

Interpolated value(s).

Return type:

numpy.ndarray