colour.NullInterpolator

class colour.NullInterpolator(x: ArrayLike, y: ArrayLike, absolute_tolerance: Floating = 10e-7, relative_tolerance: Floating = 10e-7, default: Floating = np.nan, dtype: Optional[Type[DTypeNumber]] = None)[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 (Floating) – Absolute tolerance.

  • relative_tolerance (Floating) – Relative tolerance.

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

  • dtype (Optional[Type[DTypeNumber]]) – Data type used for internal conversions.

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: Floating = 10e-7, relative_tolerance: Floating = 10e-7, default: Floating = np.nan, dtype: Optional[Type[DTypeNumber]] = None)[source]
Parameters
  • x (ArrayLike) –

  • y (ArrayLike) –

  • absolute_tolerance (Floating) –

  • relative_tolerance (Floating) –

  • default (Floating) –

  • dtype (Optional[Type[DTypeNumber]]) –

__weakref__

list of weak references to the object (if defined)

property x: numpy.ndarray

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: numpy.ndarray

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

numpy.floating

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

numpy.floating

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

numpy.floating

__call__(x: FloatingOrArrayLike) FloatingOrNDArray[source]

Evaluate the interpolator at given point(s).

Parameters

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

Returns

Interpolated value(s).

Return type

numpy.floating or numpy.ndarray