21
21
get_float_dtypes ,
22
22
get_integer_dtypes ,
23
23
has_support_aspect64 ,
24
+ numpy_version ,
24
25
)
25
26
from .third_party .cupy import testing
26
27
@@ -1822,10 +1823,7 @@ def test_2d_axis_nans(self, dt, axis_kwd, return_kwds, row):
1822
1823
if len (return_kwds ) == 0 :
1823
1824
assert_array_equal (result , expected )
1824
1825
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" :
1829
1827
# gh-26961: numpy.unique(..., return_inverse=True, axis=None)
1830
1828
# returned flatten unique_inverse till 2.0.1 version
1831
1829
expected = (
@@ -1836,6 +1834,20 @@ def test_2d_axis_nans(self, dt, axis_kwd, return_kwds, row):
1836
1834
for iv , v in zip (result , expected ):
1837
1835
assert_array_equal (iv , v )
1838
1836
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
+
1839
1851
1840
1852
class TestVsplit :
1841
1853
@pytest .mark .parametrize ("xp" , [numpy , dpnp ])
0 commit comments