19
19
20
20
import pandas .core .nanops as nanops
21
21
22
- from pandas .compat import lrange , range
22
+ from pandas .compat import lrange , range , is_platform_windows
23
23
from pandas import compat
24
24
from pandas .util .testing import (assert_series_equal , assert_almost_equal ,
25
25
assert_frame_equal , assert_index_equal )
28
28
from .common import TestData
29
29
30
30
31
+ skip_if_bottleneck_on_windows = (is_platform_windows () and
32
+ nanops ._USE_BOTTLENECK )
33
+
34
+
31
35
class TestSeriesAnalytics (TestData ):
32
36
33
37
def test_sum_zero (self ):
@@ -64,14 +68,6 @@ def test_overflow(self):
64
68
result = s .max (skipna = False )
65
69
assert int (result ) == v [- 1 ]
66
70
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
-
75
71
for dtype in ['float32' , 'float64' ]:
76
72
v = np .arange (5000000 , dtype = dtype )
77
73
s = Series (v )
@@ -84,6 +80,28 @@ def test_overflow(self):
84
80
result = s .max (skipna = False )
85
81
assert np .allclose (float (result ), v [- 1 ])
86
82
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
+
87
105
# use bottleneck if available
88
106
result = s .sum ()
89
107
assert result == v .sum (dtype = dtype )
@@ -92,6 +110,9 @@ def test_overflow(self):
92
110
result = s .max ()
93
111
assert np .allclose (float (result ), v [- 1 ])
94
112
113
+ @pytest .mark .xfail (
114
+ skip_if_bottleneck_on_windows ,
115
+ reason = "buggy bottleneck with sum overflow on windows" )
95
116
def test_sum (self ):
96
117
self ._check_stat_op ('sum' , np .sum , check_allna = True )
97
118
0 commit comments