@@ -699,6 +699,50 @@ def test_numpy_all(self, data, pos, neg):
699
699
tm .assert_raises_regex (ValueError , msg , np .all ,
700
700
SparseArray (data ), out = out )
701
701
702
+ @pytest .mark .parametrize ('data,pos,neg' , [
703
+ ([False , True , False ], True , False ),
704
+ ([0 , 2 , 0 ], 2 , 0 ),
705
+ ([0.0 , 2.0 , 0.0 ], 2.0 , 0.0 )
706
+ ])
707
+ def test_any (self , data , pos , neg ):
708
+ # GH 17570
709
+ out = SparseArray (data ).any ()
710
+ assert out
711
+
712
+ out = SparseArray (data , fill_value = pos ).any ()
713
+ assert out
714
+
715
+ data [1 ] = neg
716
+ out = SparseArray (data ).any ()
717
+ assert not out
718
+
719
+ out = SparseArray (data , fill_value = pos ).any ()
720
+ assert not out
721
+
722
+ @pytest .mark .parametrize ('data,pos,neg' , [
723
+ ([False , True , False ], True , False ),
724
+ ([0 , 2 , 0 ], 2 , 0 ),
725
+ ([0.0 , 2.0 , 0.0 ], 2.0 , 0.0 )
726
+ ])
727
+ def test_numpy_any (self , data , pos , neg ):
728
+ # GH 17570
729
+ out = np .any (SparseArray (data ))
730
+ assert out
731
+
732
+ out = np .any (SparseArray (data , fill_value = pos ))
733
+ assert out
734
+
735
+ data [1 ] = neg
736
+ out = np .any (SparseArray (data ))
737
+ assert not out
738
+
739
+ out = np .any (SparseArray (data , fill_value = pos ))
740
+ assert not out
741
+
742
+ msg = "the 'out' parameter is not supported"
743
+ tm .assert_raises_regex (ValueError , msg , np .any ,
744
+ SparseArray (data ), out = out )
745
+
702
746
def test_sum (self ):
703
747
data = np .arange (10 ).astype (float )
704
748
out = SparseArray (data ).sum ()
0 commit comments