test_set_functions.py 546 B

12345678910111213141516171819
  1. import pytest
  2. from hypothesis import given
  3. from hypothesis.extra.array_api import make_strategies_namespace
  4. from numpy import array_api as xp
  5. xps = make_strategies_namespace(xp)
  6. @pytest.mark.parametrize("func", [xp.unique_all, xp.unique_inverse])
  7. @given(xps.arrays(dtype=xps.scalar_dtypes(), shape=xps.array_shapes()))
  8. def test_inverse_indices_shape(func, x):
  9. """
  10. Inverse indices share shape of input array
  11. See https://github.com/numpy/numpy/issues/20638
  12. """
  13. out = func(x)
  14. assert out.inverse_indices.shape == x.shape