colour.utilities.xp_isin#

colour.utilities.xp_isin(element: ArrayLike, test_elements: ArrayLike, *, xp: ProtocolArrayNamespace | ModuleType | None = None, like: Any = None) NDArrayBoolean[source]#

Array API compatible implementation of numpy.isin().

Use the backend’s native isin when available (JAX, CuPy), otherwise fall back to NumPy.

Parameters:
  • element (ArrayLike) – Input array.

  • test_elements (ArrayLike) – Values against which to test each element of element.

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

  • like (Any) – Reference array whose device test_elements should be placed on when promoted to xp. Defaults to element when None.

Returns:

Boolean array of the same shape as element.

Return type:

object

Notes

  • NaN is treated as not equal to itself, matching numpy.isin() semantics; xp_isin([NaN], [NaN]) returns [False].