18
18
from pandas .tests .indexes .common import Base
19
19
20
20
21
+ # For testing division by (or of) zero for Series with length 5, this
22
+ # gives several scalar-zeros and length-5 vector-zeros
21
23
zeros = [box ([0 ] * 5 , dtype = dtype )
22
24
for box in [pd .Index , np .array ]
23
25
for dtype in [np .int64 , np .uint64 , np .float64 ]]
26
28
zeros .extend ([0 , 0.0 , long (0 )])
27
29
28
30
29
- @pytest .fixture (params = zeros )
30
- def zero (request ):
31
- """
32
- For testing division by (or of) zero for Series with length 5, this
33
- gives several scalar-zeros and length-5 vector-zeros
34
- """
35
- return request .param
36
-
37
-
38
31
def full_like (array , value ):
39
32
"""Compatibility for numpy<1.8.0
40
33
"""
@@ -174,6 +167,7 @@ def test_divmod_series(self):
174
167
for r , e in zip (result , expected ):
175
168
tm .assert_series_equal (r , e )
176
169
170
+ @pytest .mark .parametrize ('zero' , zeros )
177
171
def test_div_zero (self , zero ):
178
172
idx = self .create_index ()
179
173
@@ -184,6 +178,7 @@ def test_div_zero(self, zero):
184
178
ser_compat = Series (idx ).astype ('i8' ) / np .array (zero ).astype ('i8' )
185
179
tm .assert_series_equal (ser_compat , Series (result ))
186
180
181
+ @pytest .mark .parametrize ('zero' , zeros )
187
182
def test_floordiv_zero (self , zero ):
188
183
idx = self .create_index ()
189
184
expected = Index ([np .nan , np .inf , np .inf , np .inf , np .inf ],
@@ -194,6 +189,7 @@ def test_floordiv_zero(self, zero):
194
189
ser_compat = Series (idx ).astype ('i8' ) // np .array (zero ).astype ('i8' )
195
190
tm .assert_series_equal (ser_compat , Series (result ))
196
191
192
+ @pytest .mark .parametrize ('zero' , zeros )
197
193
def test_mod_zero (self , zero ):
198
194
idx = self .create_index ()
199
195
@@ -204,6 +200,7 @@ def test_mod_zero(self, zero):
204
200
ser_compat = Series (idx ).astype ('i8' ) % np .array (zero ).astype ('i8' )
205
201
tm .assert_series_equal (ser_compat , Series (result ))
206
202
203
+ @pytest .mark .parametrize ('zero' , zeros )
207
204
def test_divmod_zero (self , zero ):
208
205
idx = self .create_index ()
209
206
0 commit comments