@@ -641,6 +641,13 @@ def test_sum_inf(self):
641
641
s2 [5 :8 ] = np .nan
642
642
assert_almost_equal (s .sum (), s2 .sum ())
643
643
644
+ import pandas .core .nanops as nanops
645
+ arr = np .random .randn (100 , 100 ).astype ('f4' )
646
+ arr [:, 2 ] = np .inf
647
+ res = nanops .nansum (arr , axis = 1 )
648
+ expected = nanops ._nansum (arr , axis = 1 )
649
+ assert_almost_equal (res , expected )
650
+
644
651
def test_mean (self ):
645
652
self ._check_stat_op ('mean' , np .mean )
646
653
@@ -686,33 +693,46 @@ def test_cumprod(self):
686
693
687
694
def _check_stat_op (self , name , alternate , check_objects = False ):
688
695
from pandas import DateRange
696
+ import pandas .core .nanops as nanops
689
697
690
- f = getattr (Series , name )
698
+ def testit ():
699
+ f = getattr (Series , name )
691
700
692
- # add some NaNs
693
- self .series [5 :15 ] = np .NaN
701
+ # add some NaNs
702
+ self .series [5 :15 ] = np .NaN
694
703
695
- # skipna or no
696
- self .assert_ (notnull (f (self .series )))
697
- self .assert_ (isnull (f (self .series , skipna = False )))
704
+ # skipna or no
705
+ self .assert_ (notnull (f (self .series )))
706
+ self .assert_ (isnull (f (self .series , skipna = False )))
698
707
699
- # check the result is correct
700
- nona = self .series .dropna ()
701
- assert_almost_equal (f (nona ), alternate (nona ))
708
+ # check the result is correct
709
+ nona = self .series .dropna ()
710
+ assert_almost_equal (f (nona ), alternate (nona ))
711
+
712
+ allna = self .series * nan
713
+ self .assert_ (np .isnan (f (allna )))
714
+
715
+ # dtype=object with None, it works!
716
+ s = Series ([1 , 2 , 3 , None , 5 ])
717
+ f (s )
718
+
719
+ # check DateRange
720
+ if check_objects :
721
+ s = Series (DateRange ('1/1/2000' , periods = 10 ))
722
+ res = f (s )
723
+ exp = alternate (s )
724
+ self .assertEqual (res , exp )
725
+
726
+ testit ()
727
+
728
+ try :
729
+ import bottleneck as bn
730
+ nanops ._USE_BOTTLENECK = False
731
+ testit ()
732
+ nanops ._USE_BOTTLENECK = True
733
+ except ImportError :
734
+ pass
702
735
703
- allna = self .series * nan
704
- self .assert_ (np .isnan (f (allna )))
705
-
706
- # dtype=object with None, it works!
707
- s = Series ([1 , 2 , 3 , None , 5 ])
708
- f (s )
709
-
710
- # check DateRange
711
- if check_objects :
712
- s = Series (DateRange ('1/1/2000' , periods = 10 ))
713
- res = f (s )
714
- exp = alternate (s )
715
- self .assertEqual (res , exp )
716
736
717
737
def _check_accum_op (self , name ):
718
738
func = getattr (np , name )
0 commit comments