Skip to content

Commit 85b75f9

Browse files
committed
TST: test both with and without bottleneck, GH #91
1 parent 71e9046 commit 85b75f9

File tree

2 files changed

+46
-22
lines changed

2 files changed

+46
-22
lines changed

RELEASE.rst

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ pandas 0.7.0
126126
#477)
127127
- Improve DataFrame.to_string and console formatting to be more consistent in
128128
the number of displayed digits (GH #395)
129+
- Use bottleneck if available for performing NaN-friendly statistical
130+
operations that it implemented (GH #91)
129131

130132
**Bug fixes**
131133

@@ -182,13 +184,15 @@ pandas 0.7.0
182184
keywords passed
183185
- Fix exception caused by parser converter returning strings (GH #583)
184186
- Fix MultiIndex formatting bug with integer names (GH #601)
187+
- Fix bug in handling of non-numeric aggregates in Series.groupby (GH #612)
185188

186189
Thanks
187190
------
188191
- Craig Austin
189192
- Marius Cobzarenco
190193
- Mario Gamboa-Cavazos
191194
- Arthur Gerigk
195+
- Yaroslav Halchenko
192196
- Matt Harrison
193197
- Andreas Hilboll
194198
- Luc Kesters

pandas/tests/test_series.py

+42-22
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,13 @@ def test_sum_inf(self):
641641
s2[5:8] = np.nan
642642
assert_almost_equal(s.sum(), s2.sum())
643643

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+
644651
def test_mean(self):
645652
self._check_stat_op('mean', np.mean)
646653

@@ -686,33 +693,46 @@ def test_cumprod(self):
686693

687694
def _check_stat_op(self, name, alternate, check_objects=False):
688695
from pandas import DateRange
696+
import pandas.core.nanops as nanops
689697

690-
f = getattr(Series, name)
698+
def testit():
699+
f = getattr(Series, name)
691700

692-
# add some NaNs
693-
self.series[5:15] = np.NaN
701+
# add some NaNs
702+
self.series[5:15] = np.NaN
694703

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)))
698707

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
702735

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)
716736

717737
def _check_accum_op(self, name):
718738
func = getattr(np, name)

0 commit comments

Comments
 (0)