colour.LinearInterpolator#

class colour.LinearInterpolator(x: ArrayLike, y: ArrayLike, dtype: Type[DTypeReal] | None = None, *args: Any, **kwargs: Any)[source]#

Bases: object

Perform linear interpolation of a 1-D function.

This class provides a wrapper around NumPy’s linear interpolation functionality for interpolating between specified data points.

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

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

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

  • args (Any)

  • kwargs (Any)

Attributes

Methods

Notes

  • This class is a wrapper around numpy.interp definition.

Examples

Interpolating a single numeric variable:

>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500])
>>> x = np.arange(len(y))
>>> f = LinearInterpolator(x, y)
>>> f(0.5)
7.64...

Interpolating an ArrayLike variable:

>>> f([0.25, 0.75])
array([ 6.7825,  8.5075])
__init__(x: ArrayLike, y: ArrayLike, dtype: Type[DTypeReal] | None = None, *args: Any, **kwargs: Any) None[source]#
Parameters:
Return type:

None

property x: NDArrayFloat#

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

Parameters:

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

Returns:

Independent \(x\) variable.

Return type:

numpy.ndarray

Raises:

AssertionError – If the provided value has not exactly one dimension.

property y: NDArrayFloat#

Getter and setter 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

Raises:

AssertionError – If the provided value has not exactly one dimension.

__call__(x: ArrayLike) NDArrayFloat[source]#

Evaluate the interpolating polynomial at specified point(s).

Parameters:

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

Returns:

Interpolated value(s).

Return type:

numpy.ndarray

__weakref__#

list of weak references to the object