colour.utilities.as_array#

colour.utilities.as_array(a: Union[NumberOrArrayLike, NestedSequence[NumberOrArrayLike]], dtype: Optional[Type[DType]] = None) NDArray[source]#

Convert given variable \(a\) to numpy.ndarray using given numpy.dtype.

Parameters
  • a (Union[NumberOrArrayLike, NestedSequence[NumberOrArrayLike]]) – Variable to convert.

  • dtype (Optional[Type[DType]]) – numpy.dtype to use for conversion, default to the numpy.dtype defined by the colour.constant.DEFAULT_FLOAT_DTYPE attribute.

Returns

Variable \(a\) converted to numpy.ndarray.

Return type

numpy.ndarray

Examples

>>> as_array([1, 2, 3])  
array([1, 2, 3]...)
>>> as_array([1, 2, 3], dtype=DEFAULT_FLOAT_DTYPE)
array([ 1.,  2.,  3.])