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:
objectImplement 1-D function null interpolation.
This interpolator returns existing \(y\) values when called with \(x\) values within specified tolerances, and returns a default value when outside tolerances. Unlike traditional interpolators that estimate intermediate values, this null interpolator only returns exact matches within tolerance bounds.
- 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...
- __weakref__#
list of weak references to the object
- __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]#
- 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:
- 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:
- Raises:
AssertionError – If the provided value has not exactly one dimension.
- property relative_tolerance: float#
Getter and setter property for the relative tolerance for numerical comparisons.
- Parameters:
value – Value to set the relative tolerance for numerical comparisons with.
- Returns:
Relative tolerance for numerical comparisons.
- Return type:
- Raises:
AssertionError – If the value is not numeric.
- property absolute_tolerance: float#
Getter and setter property for the absolute tolerance for numerical comparisons.
- Parameters:
value – Value to set the absolute tolerance for numerical comparisons with.
- Returns:
Absolute tolerance for numerical comparisons.
- Return type:
- Raises:
AssertionError – If the value is not numeric.
- property default: float#
Getter and setter property for the default value for call outside tolerances.
- Parameters:
value – Value to set the default value with for call outside tolerances.
- Returns:
Default value for call outside tolerances.
- Return type:
- Raises:
AssertionError – If the value is not numeric.
- __call__(x: ArrayLike) NDArrayFloat[source]#
Evaluate the interpolator at specified point(s).
- Parameters:
x (ArrayLike) – Point(s) to evaluate the interpolant at.
- Returns:
Interpolated value(s).
- Return type: