@@ -655,6 +655,50 @@ def test_fillna_overlap(self):
655
655
656
656
class TestSparseArrayAnalytics (object ):
657
657
658
+ @pytest .mark .parametrize ('data,pos,neg' , [
659
+ ([True , True , True ], True , False ),
660
+ ([1 , 2 , 1 ], 1 , 0 ),
661
+ ([1.0 , 2.0 , 1.0 ], 1.0 , 0.0 )
662
+ ])
663
+ def test_all (self , data , pos , neg ):
664
+ # GH 17570
665
+ out = SparseArray (data ).all ()
666
+ assert out
667
+
668
+ out = SparseArray (data , fill_value = pos ).all ()
669
+ assert out
670
+
671
+ data [1 ] = neg
672
+ out = SparseArray (data ).all ()
673
+ assert not out
674
+
675
+ out = SparseArray (data , fill_value = pos ).all ()
676
+ assert not out
677
+
678
+ @pytest .mark .parametrize ('data,pos,neg' , [
679
+ ([True , True , True ], True , False ),
680
+ ([1 , 2 , 1 ], 1 , 0 ),
681
+ ([1.0 , 2.0 , 1.0 ], 1.0 , 0.0 )
682
+ ])
683
+ def test_numpy_all (self , data , pos , neg ):
684
+ # GH 17570
685
+ out = np .all (SparseArray (data ))
686
+ assert out
687
+
688
+ out = np .all (SparseArray (data , fill_value = pos ))
689
+ assert out
690
+
691
+ data [1 ] = neg
692
+ out = np .all (SparseArray (data ))
693
+ assert not out
694
+
695
+ out = np .all (SparseArray (data , fill_value = pos ))
696
+ assert not out
697
+
698
+ msg = "the 'out' parameter is not supported"
699
+ tm .assert_raises_regex (ValueError , msg , np .all ,
700
+ SparseArray (data ), out = out )
701
+
658
702
def test_sum (self ):
659
703
data = np .arange (10 ).astype (float )
660
704
out = SparseArray (data ).sum ()
0 commit comments