colour.utilities.xp_unique#
- colour.utilities.xp_unique(a: ArrayLike, *, xp: ProtocolArrayNamespace | ModuleType | None = None, **kwargs: Any) NDArray | tuple[NDArray, ...][source]#
Array API compatible implementation of
numpy.unique()with extra keyword arguments such as return_index and axis.The Array API standard only provides
xp.unique_valuesand related functions without return_index or axis support. This helper tries the backend’s nativeuniquefirst, falling back to NumPy if the keywords are unsupported.- Parameters:
a (ArrayLike) – Input array.
xp (ProtocolArrayNamespace | ModuleType | None) – Array namespace module. If None, derived from
a.**kwargs (Any) – Extra keyword arguments (e.g.,
return_index,axis).
- Returns:
Unique values (and optional indices).
- Return type: