colour.utilities.as_float#
- colour.utilities.as_float(a: float | DTypeFloat, dtype: Type[DTypeFloat] | None = None) DTypeFloat[source]#
- colour.utilities.as_float(a: NDArray | Sequence[float], dtype: Type[DTypeFloat] | None = None) NDArrayFloat
- colour.utilities.as_float(a: ArrayLike, dtype: Type[DTypeFloat] | None = None) DTypeFloat | NDArrayFloat
Convert the specified variable \(a\) to
numpy.floatingusing the specifiednumpy.dtype.If variable \(a\) is not a scalar or 0-dimensional, it is converted to
numpy.ndarray.- Parameters:
a (ArrayLike) – Variable \(a\) to convert.
dtype (Type[DTypeFloat] | None) –
numpy.dtypeto use for conversion, default to thenumpy.dtypedefined by thecolour.constant.DTYPE_FLOAT_DEFAULTattribute.
- Returns:
Variable \(a\) converted to
numpy.floating.- Return type:
Examples
>>> as_float(np.array(1)) 1.0 >>> as_float(np.array([1])) array([ 1.]) >>> as_float(np.arange(10)) array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])