|
5 | 5 |
|
6 | 6 | import pytest |
7 | 7 | from hypothesis import assume, given |
| 8 | +from hypothesis import strategies as st |
8 | 9 |
|
9 | 10 | from . import _array_module as xp |
10 | 11 | from . import dtype_helpers as dh |
@@ -256,3 +257,44 @@ def test_unique_values(x): |
256 | 257 | except Exception as exc: |
257 | 258 | ph.add_note(exc, repro_snippet) |
258 | 259 | raise |
| 260 | + |
| 261 | + |
| 262 | +@pytest.mark.min_version("2025.12") |
| 263 | +class TestIsin: |
| 264 | + @given( |
| 265 | + hh.mutually_promotable_dtypes(2, dtypes=dh.all_int_dtypes), |
| 266 | + hh.kwargs(invert=st.booleans()), |
| 267 | + st.data() |
| 268 | + ) |
| 269 | + def test_isin(self, dt, kw, data): |
| 270 | + x1 = data.draw(hh.arrays(dtype=dt[0], shape=hh.shapes())) |
| 271 | + x2 = data.draw(hh.arrays(dtype=dt[1], shape=hh.shapes())) |
| 272 | + |
| 273 | + repro_snippet = ph.format_snippet(f"xp.isin({x1!r}, {x2!r}, **kw) with {kw = }") |
| 274 | + try: |
| 275 | + out = xp.isin(x1, x2, **kw) |
| 276 | + |
| 277 | + assert out.dtype == xp.bool |
| 278 | + assert out.shape == x1.shape |
| 279 | + # TODO value tests |
| 280 | + except Exception as exc: |
| 281 | + ph.add_note(exc, repro_snippet) |
| 282 | + raise |
| 283 | + |
| 284 | + @given( |
| 285 | + x1x2=hh.array_and_py_scalar(dh.all_int_dtypes), |
| 286 | + kw=hh.kwargs(invert=st.booleans()) |
| 287 | + ) |
| 288 | + def test_isin_scalars(self, x1x2, kw): |
| 289 | + x1, x2 = x1x2 |
| 290 | + |
| 291 | + repro_snippet = ph.format_snippet(f"xp.isin({x1!r}, {x2!r}, **kw) with {kw = }") |
| 292 | + try: |
| 293 | + out = xp.isin(x1, x2, **kw) |
| 294 | + |
| 295 | + assert out.dtype == xp.bool |
| 296 | + assert out.shape == () if isinstance(x1, int) else x1.shape |
| 297 | + # TODO value tests |
| 298 | + except Exception as exc: |
| 299 | + ph.add_note(exc, repro_snippet) |
| 300 | + raise |
0 commit comments