Skip to content

Commit bfcec3e

Browse files
committed
Add more tests
1 parent 01f92a5 commit bfcec3e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

dpnp/tests/test_manipulation.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
get_float_dtypes,
2222
get_integer_dtypes,
2323
has_support_aspect64,
24+
numpy_version,
2425
)
2526
from .third_party.cupy import testing
2627

@@ -1822,10 +1823,7 @@ def test_2d_axis_nans(self, dt, axis_kwd, return_kwds, row):
18221823
if len(return_kwds) == 0:
18231824
assert_array_equal(result, expected)
18241825
else:
1825-
if (
1826-
len(axis_kwd) == 0
1827-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.1"
1828-
):
1826+
if len(axis_kwd) == 0 and numpy_version() < "2.0.1":
18291827
# gh-26961: numpy.unique(..., return_inverse=True, axis=None)
18301828
# returned flatten unique_inverse till 2.0.1 version
18311829
expected = (
@@ -1836,6 +1834,20 @@ def test_2d_axis_nans(self, dt, axis_kwd, return_kwds, row):
18361834
for iv, v in zip(result, expected):
18371835
assert_array_equal(iv, v)
18381836

1837+
@testing.with_requires("numpy>=2.0")
1838+
@pytest.mark.parametrize(
1839+
"func",
1840+
["unique_all", "unique_counts", "unique_inverse", "unique_values"],
1841+
)
1842+
def test_array_api_functions(self, func):
1843+
a = numpy.array([numpy.nan, 1, 4, 1, 3, 4, 5, 5, 1])
1844+
ia = dpnp.array(a)
1845+
1846+
result = getattr(dpnp, func)(ia)
1847+
expected = getattr(numpy, func)(a)
1848+
for iv, v in zip(result, expected):
1849+
assert_array_equal(iv, v)
1850+
18391851

18401852
class TestVsplit:
18411853
@pytest.mark.parametrize("xp", [numpy, dpnp])

0 commit comments

Comments
 (0)