colour.utilities.as_complex_array#

colour.utilities.as_complex_array(a: ArrayLike, dtype: Type[DTypeComplex] | None = None) → NDArrayComplex[source]#

Convert the specified variable \(a\) to a complex array using the specified numpy.dtype.

This is a namespace-aware boundary helper. When Array API dispatch is enabled and \(a\) is a non-NumPy array (e.g. JAX, PyTorch), the result is returned in \(a\)’s native namespace, on its device, and cast to dtype. Otherwise the result is a numpy.ndarray.

Parameters:
Returns:

Variable \(a\) converted to a complex array in the input’s namespace.

Return type:

numpy.ndarray or backend tensor

Examples

>>> as_complex_array([1, 2, 3])
array([1.+0.j, 2.+0.j, 3.+0.j])
>>> as_complex_array([1 + 2j, 3 + 4j])
array([1.+2.j, 3.+4.j])