Skip to content

Commit 4ba25b6

Browse files
committed
ENH: add a basic test of isin
1 parent 602b412 commit 4ba25b6

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

array_api_tests/_array_module.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def __repr__(self):
3535
_funcs += ["take", "isdtype", "conj", "imag", "real"] # TODO: bump spec and update array-api-tests to new spec layout
3636
_top_level_attrs = _dtypes + _constants + _funcs + stubs.EXTENSIONS + ["fft"]
3737

38+
_top_level_attrs += ['isin'] # FIXME: until the spec is not updated
39+
3840
for attr in _top_level_attrs:
3941
try:
4042
globals()[attr] = getattr(xp, attr)

array_api_tests/test_set_functions.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77
from hypothesis import assume, given
8+
from hypothesis import strategies as st
89

910
from . import _array_module as xp
1011
from . import dtype_helpers as dh
@@ -256,3 +257,23 @@ def test_unique_values(x):
256257
except Exception as exc:
257258
ph.add_note(exc, repro_snippet)
258259
raise
260+
261+
262+
@given(
263+
*hh.two_mutual_arrays(two_shapes=st.tuples(hh.shapes(), hh.shapes())),
264+
hh.kwargs(invert=st.booleans())
265+
)
266+
def test_isin(x1, x2, kw):
267+
print("\nx1 = ", type(x1))
268+
print(x1.shape, x2.shape, x1.dtype, x2.dtype, kw)
269+
270+
repro_snippet = ph.format_snippet(f"xp.isin({x1!r}, {x2!r}, **kw) with {kw = }")
271+
try:
272+
out = xp.isin(x1, x2, **kw)
273+
274+
assert out.dtype == xp.bool
275+
assert out.shape == x1.shape
276+
# TODO value tests
277+
except Exception as exc:
278+
ph.add_note(exc, repro_snippet)
279+
raise

0 commit comments

Comments
 (0)