colour.utilities.fill_nan#

colour.utilities.fill_nan(a: ArrayLike, method: Union[Literal['Interpolation', 'Constant'], str] = 'Interpolation', default: Real = 0) numpy.ndarray[Any, numpy.dtype[numpy._typing._array_like._ScalarType_co]][source]#

Fill given array \(a\) NaN values according to given method.

Parameters
  • a (ArrayLike) – Array \(a\) to fill the NaNs of.

  • method (Union[Literal['Interpolation', 'Constant'], str]) – Interpolation method linearly interpolates through the NaN values, Constant method replaces NaN values with default.

  • default (Real) – Value to use with the Constant method.

Returns

NaNs filled array \(a\).

Return type

numpy.ndarray

Examples

>>> a = np.array([0.1, 0.2, np.nan, 0.4, 0.5])
>>> fill_nan(a)
array([ 0.1,  0.2,  0.3,  0.4,  0.5])
>>> fill_nan(a, method="Constant")
array([ 0.1,  0.2,  0. ,  0.4,  0.5])