diff --git a/array_api_strict/_set_functions.py b/array_api_strict/_set_functions.py index fe40b0d..ce8c56b 100644 --- a/array_api_strict/_set_functions.py +++ b/array_api_strict/_set_functions.py @@ -130,4 +130,4 @@ def isin(x1: Array | int, x2: Array | int, /, *, invert: bool = False) -> Array: # Call result type here just to raise on disallowed type combinations _result_type(x1.dtype, x2.dtype) # x1, x2 = Array._normalize_two_args(x1, x2) # no need to change 0D -> 1D here - return Array._new(np.isin(x1._array, x2._array), device=x1.device) + return Array._new(np.isin(x1._array, x2._array, invert=invert), device=x1.device) diff --git a/array_api_strict/tests/test_set_functions.py b/array_api_strict/tests/test_set_functions.py index 7356b0e..453f3e7 100644 --- a/array_api_strict/tests/test_set_functions.py +++ b/array_api_strict/tests/test_set_functions.py @@ -17,3 +17,9 @@ def test_inverse_indices_shape(func, x): """ out = func(x) assert out.inverse_indices.shape == x.shape + + +def test_isin_invert(): + x = xp.asarray([1, 2, 3]) + excluded = xp.asarray([1, 3]) + assert xp.all(xp.isin(x, excluded, invert=True) == xp.asarray([False, True, False]))