@@ -1710,6 +1710,23 @@ def test_sparse(self):
1710
1710
assert_equal (np .nonzero (c )[0 ],
1711
1711
np .concatenate ((np .arange (10 + i , 20 + i ), [20 + i * 2 ])))
1712
1712
1713
+ @pytest .mark .parametrize ('dtype' , [np .float32 , np .float64 ])
1714
+ def test_nonzero_float_dtypes (self , dtype ):
1715
+ rng = np .random .default_rng (seed = 10 )
1716
+ x = ((2 ** 33 )* rng .normal (size = 100 )).astype (dtype )
1717
+ x [rng .choice (50 , size = 100 )] = 0
1718
+ idxs = np .nonzero (x )[0 ]
1719
+ assert_equal (np .array_equal (np .where (x != 0 )[0 ], idxs ), True )
1720
+
1721
+ @pytest .mark .parametrize ('dtype' , [bool , np .int8 , np .int16 , np .int32 , np .int64 ,
1722
+ np .uint8 , np .uint16 , np .uint32 , np .uint64 ])
1723
+ def test_nonzero_integer_dtypes (self , dtype ):
1724
+ rng = np .random .default_rng (seed = 10 )
1725
+ x = rng .integers (0 , 255 , size = 100 ).astype (dtype )
1726
+ x [rng .choice (50 , size = 100 )] = 0
1727
+ idxs = np .nonzero (x )[0 ]
1728
+ assert_equal (np .array_equal (np .where (x != 0 )[0 ], idxs ), True )
1729
+
1713
1730
def test_return_type (self ):
1714
1731
class C (np .ndarray ):
1715
1732
pass
0 commit comments