colour.utilities.fill_nan

colour.utilities.fill_nan(a: ArrayLike, method: Union[Literal['Interpolation', 'Constant'], str] = 'Interpolation', default: Number = 0) numpy.ndarray[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 (Number) – 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])