colour.utilities.as_array#
- colour.utilities.as_array(a: NumberOrArrayLike | NestedSequence[NumberOrArrayLike], dtype: Type[DType] | None = None) NDArray[source]#
Convert given variable \(a\) to
numpy.ndarrayusing givennumpy.dtype.- Parameters:
a (Union[NumberOrArrayLike, NestedSequence[NumberOrArrayLike]]) – Variable to convert.
dtype (Optional[Type[DType]]) –
numpy.dtypeto use for conversion, default to thenumpy.dtypedefined by thecolour.constant.DEFAULT_FLOAT_DTYPEattribute.
- Returns:
Variable \(a\) converted to
numpy.ndarray.- Return type:
Examples
>>> as_array([1, 2, 3]) array([1, 2, 3]...) >>> as_array([1, 2, 3], dtype=DEFAULT_FLOAT_DTYPE) array([ 1., 2., 3.])