@@ -1685,6 +1685,7 @@ def test_axis_list(self, axis):
1685
1685
expected = numpy .unique (a , axis = axis )
1686
1686
assert_array_equal (result , expected )
1687
1687
1688
+ @testing .with_requires ("numpy>=2.0.1" )
1688
1689
@pytest .mark .parametrize ("dt" , get_all_dtypes (no_none = True ))
1689
1690
@pytest .mark .parametrize (
1690
1691
"axis_kwd" ,
@@ -1716,17 +1717,6 @@ def test_2d_axis(self, dt, axis_kwd, return_kwds):
1716
1717
if len (return_kwds ) == 0 :
1717
1718
assert_array_equal (result , expected )
1718
1719
else :
1719
- if (
1720
- len (axis_kwd ) == 0
1721
- and numpy .lib .NumpyVersion (numpy .__version__ ) < "2.0.1"
1722
- ):
1723
- # gh-26961: numpy.unique(..., return_inverse=True, axis=None)
1724
- # returned flatten unique_inverse till 2.0.1 version
1725
- expected = (
1726
- expected [:2 ]
1727
- + (expected [2 ].reshape (a .shape ),)
1728
- + expected [3 :]
1729
- )
1730
1720
for iv , v in zip (result , expected ):
1731
1721
assert_array_equal (iv , v )
1732
1722
@@ -1756,17 +1746,14 @@ def test_1d_axis(self, axis):
1756
1746
expected = numpy .unique (a , axis = axis )
1757
1747
assert_array_equal (result , expected )
1758
1748
1749
+ @testing .with_requires ("numpy>=2.0.1" )
1759
1750
@pytest .mark .parametrize ("axis" , [None , 0 , - 1 ])
1760
1751
def test_2d_axis_inverse (self , axis ):
1761
1752
a = numpy .array ([[4 , 4 , 3 ], [2 , 2 , 1 ], [2 , 2 , 1 ], [4 , 4 , 3 ]])
1762
1753
ia = dpnp .array (a )
1763
1754
1764
1755
result = dpnp .unique (ia , return_inverse = True , axis = axis )
1765
1756
expected = numpy .unique (a , return_inverse = True , axis = axis )
1766
- if axis is None and numpy .lib .NumpyVersion (numpy .__version__ ) < "2.0.1" :
1767
- # gh-26961: numpy.unique(..., return_inverse=True, axis=None)
1768
- # returned flatten unique_inverse till 2.0.1 version
1769
- expected = expected [:1 ] + (expected [1 ].reshape (a .shape ),)
1770
1757
1771
1758
for iv , v in zip (result , expected ):
1772
1759
assert_array_equal (iv , v )
@@ -1847,6 +1834,7 @@ def test_1d_equal_nan_axis0(self):
1847
1834
expected = numpy .unique (a , axis = 0 , equal_nan = True )
1848
1835
assert_array_equal (result , expected )
1849
1836
1837
+ @testing .with_requires ("numpy>=2.0.1" )
1850
1838
@pytest .mark .parametrize ("dt" , get_float_complex_dtypes ())
1851
1839
@pytest .mark .parametrize (
1852
1840
"axis_kwd" ,
@@ -1888,14 +1876,6 @@ def test_2d_axis_nans(self, dt, axis_kwd, return_kwds, row):
1888
1876
if len (return_kwds ) == 0 :
1889
1877
assert_array_equal (result , expected )
1890
1878
else :
1891
- if len (axis_kwd ) == 0 and numpy_version () < "2.0.1" :
1892
- # gh-26961: numpy.unique(..., return_inverse=True, axis=None)
1893
- # returned flatten unique_inverse till 2.0.1 version
1894
- expected = (
1895
- expected [:2 ]
1896
- + (expected [2 ].reshape (a .shape ),)
1897
- + expected [3 :]
1898
- )
1899
1879
for iv , v in zip (result , expected ):
1900
1880
assert_array_equal (iv , v )
1901
1881
0 commit comments