From 7642434594c90f27c27bfb742927447f15b7e09b Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sun, 11 Jan 2026 15:12:51 +0100 Subject: [PATCH] ENH: add a basic test of isin --- array_api_tests/test_set_functions.py | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/array_api_tests/test_set_functions.py b/array_api_tests/test_set_functions.py index 8a6f7a9d..0d48d871 100644 --- a/array_api_tests/test_set_functions.py +++ b/array_api_tests/test_set_functions.py @@ -5,6 +5,7 @@ import pytest from hypothesis import assume, given +from hypothesis import strategies as st from . import _array_module as xp from . import dtype_helpers as dh @@ -256,3 +257,44 @@ def test_unique_values(x): except Exception as exc: ph.add_note(exc, repro_snippet) raise + + +@pytest.mark.min_version("2025.12") +class TestIsin: + @given( + hh.mutually_promotable_dtypes(2, dtypes=dh.all_int_dtypes), + hh.kwargs(invert=st.booleans()), + st.data() + ) + def test_isin(self, dt, kw, data): + x1 = data.draw(hh.arrays(dtype=dt[0], shape=hh.shapes())) + x2 = data.draw(hh.arrays(dtype=dt[1], shape=hh.shapes())) + + repro_snippet = ph.format_snippet(f"xp.isin({x1!r}, {x2!r}, **kw) with {kw = }") + try: + out = xp.isin(x1, x2, **kw) + + assert out.dtype == xp.bool + assert out.shape == x1.shape + # TODO value tests + except Exception as exc: + ph.add_note(exc, repro_snippet) + raise + + @given( + x1x2=hh.array_and_py_scalar(dh.all_int_dtypes), + kw=hh.kwargs(invert=st.booleans()) + ) + def test_isin_scalars(self, x1x2, kw): + x1, x2 = x1x2 + + repro_snippet = ph.format_snippet(f"xp.isin({x1!r}, {x2!r}, **kw) with {kw = }") + try: + out = xp.isin(x1, x2, **kw) + + assert out.dtype == xp.bool + assert out.shape == () if isinstance(x1, int) else x1.shape + # TODO value tests + except Exception as exc: + ph.add_note(exc, repro_snippet) + raise