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