array_api_extra.isin

array_api_extra.isin(a, b, /, *, assume_unique=False, invert=False, kind=None, xp=None)

Determine whether each element in a is present in b.

Return a boolean array of the same shape as a that is True for elements that are in b and False otherwise.

Parameters:
  • a (array) – Input elements.

  • b (array) – The elements against which to test each element of a.

  • assume_unique (bool, optional) – If True, the input arrays are both assumed to be unique which can speed up the calculation. Default: False.

  • invert (bool, optional) – If True, the values in the returned array are inverted. Default: False.

  • kind (str | None, optional) – The algorithm or method to use. This will not affect the final result, but will affect the speed and memory use. For NumPy the options are {None, “sort”, “table”}. For Jax the mapped parameter is instead method and the options are {“compare_all”, “binary_search”, “sort”, and “auto” (default)} For CuPy, Dask, Torch and the default case this parameter is not present and thus ignored. Default: None.

  • xp (array_namespace, optional) – The standard-compatible namespace for a and b. Default: infer.

Returns:

An array having the same shape as that of a that is True for elements that are in b and False otherwise.

Return type:

array