1919
2020import pandas .core .nanops as nanops
2121
22- from pandas .compat import lrange , range
22+ from pandas .compat import lrange , range , is_platform_windows
2323from pandas import compat
2424from pandas .util .testing import (assert_series_equal , assert_almost_equal ,
2525 assert_frame_equal , assert_index_equal )
2828from .common import TestData
2929
3030
31+ skip_if_bottleneck_on_windows = (is_platform_windows () and
32+ nanops ._USE_BOTTLENECK )
33+
34+
3135class TestSeriesAnalytics (TestData ):
3236
3337 def test_sum_zero (self ):
@@ -64,14 +68,6 @@ def test_overflow(self):
6468 result = s .max (skipna = False )
6569 assert int (result ) == v [- 1 ]
6670
67- # use bottleneck if available
68- result = s .sum ()
69- assert int (result ) == v .sum (dtype = 'int64' )
70- result = s .min ()
71- assert int (result ) == 0
72- result = s .max ()
73- assert int (result ) == v [- 1 ]
74-
7571 for dtype in ['float32' , 'float64' ]:
7672 v = np .arange (5000000 , dtype = dtype )
7773 s = Series (v )
@@ -84,6 +80,28 @@ def test_overflow(self):
8480 result = s .max (skipna = False )
8581 assert np .allclose (float (result ), v [- 1 ])
8682
83+ @pytest .mark .xfail (
84+ skip_if_bottleneck_on_windows ,
85+ reason = "buggy bottleneck with sum overflow on windows" )
86+ def test_overflow_with_bottleneck (self ):
87+ # GH 6915
88+ # overflowing on the smaller int dtypes
89+ for dtype in ['int32' , 'int64' ]:
90+ v = np .arange (5000000 , dtype = dtype )
91+ s = Series (v )
92+
93+ # use bottleneck if available
94+ result = s .sum ()
95+ assert int (result ) == v .sum (dtype = 'int64' )
96+ result = s .min ()
97+ assert int (result ) == 0
98+ result = s .max ()
99+ assert int (result ) == v [- 1 ]
100+
101+ for dtype in ['float32' , 'float64' ]:
102+ v = np .arange (5000000 , dtype = dtype )
103+ s = Series (v )
104+
87105 # use bottleneck if available
88106 result = s .sum ()
89107 assert result == v .sum (dtype = dtype )
@@ -92,6 +110,9 @@ def test_overflow(self):
92110 result = s .max ()
93111 assert np .allclose (float (result ), v [- 1 ])
94112
113+ @pytest .mark .xfail (
114+ skip_if_bottleneck_on_windows ,
115+ reason = "buggy bottleneck with sum overflow on windows" )
95116 def test_sum (self ):
96117 self ._check_stat_op ('sum' , np .sum , check_allna = True )
97118
0 commit comments