colour.utilities.as_array#
- colour.utilities.as_array(a: ArrayLike, dtype: Type[DType] | None = None) ndarray[Any, dtype[_ScalarType_co]] [source]#
Convert given variable \(a\) to
numpy.ndarray
using givennumpy.dtype
.- Parameters:
a (ArrayLike) – Variable to convert.
dtype (Type[DType] | None) –
numpy.dtype
to use for conversion, default to thenumpy.dtype
defined by thecolour.constant.DEFAULT_FLOAT_DTYPE
attribute.
- 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.])