# colour.LinearInterpolator¶

class colour.LinearInterpolator(x, y, dtype=None)[source]

Bases: object

Linearly interpolates a 1-D function.

Parameters
• x (array_like) – Independent $$x$$ variable values corresponding with $$y$$ variable.

• y (array_like) – Dependent and already known $$y$$ variable values to interpolate.

• dtype (type) – Data type used for internal conversions.

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

>>> f([0.25, 0.75])
array([ 6.7825,  8.5075])

__init__(x, y, dtype=None)[source]
property x

Getter and setter property for the independent $$x$$ variable.

Parameters

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

Returns

Independent $$x$$ variable.

Return type

array_like

property y

Getter and setter property for the dependent and already known $$y$$ variable.

Parameters

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

Returns

Dependent and already known $$y$$ variable.

Return type

array_like

__call__(x)[source]

Evaluates the interpolating polynomial at given point(s).

Parameters

x (numeric or array_like) – Point(s) to evaluate the interpolant at.

Returns

Interpolated value(s).

Return type

float or ndarray

__weakref__

list of weak references to the object (if defined)