colour.utilities.xp_astype#

colour.utilities.xp_astype(a: ArrayLike, dtype: Any, *, xp: ProtocolArrayNamespace | ModuleType | None = None) NDArray[source]#

Array API compatible implementation of numpy.ndarray.astype().

NumPy uses a.astype(dtype) while the Array API standard uses xp.astype(a, dtype) with backend-native dtype objects.

Parameters:
  • a (ArrayLike) – Array to cast.

  • dtype (Any) – Target dtype (NumPy dtype accepted, automatically translated for non-NumPy backends).

  • xp (ProtocolArrayNamespace | ModuleType | None) – Array namespace module. If None, derived from a.

Returns:

Cast array.

Return type:

object