1818from pandas .tests .indexes .common import Base
1919
2020
21+ # For testing division by (or of) zero for Series with length 5, this
22+ # gives several scalar-zeros and length-5 vector-zeros
2123zeros = [box ([0 ] * 5 , dtype = dtype )
2224 for box in [pd .Index , np .array ]
2325 for dtype in [np .int64 , np .uint64 , np .float64 ]]
2628zeros .extend ([0 , 0.0 , long (0 )])
2729
2830
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-
3831def full_like (array , value ):
3932 """Compatibility for numpy<1.8.0
4033 """
@@ -174,6 +167,7 @@ def test_divmod_series(self):
174167 for r , e in zip (result , expected ):
175168 tm .assert_series_equal (r , e )
176169
170+ @pytest .mark .parametrize ('zero' , zeros )
177171 def test_div_zero (self , zero ):
178172 idx = self .create_index ()
179173
@@ -184,6 +178,7 @@ def test_div_zero(self, zero):
184178 ser_compat = Series (idx ).astype ('i8' ) / np .array (zero ).astype ('i8' )
185179 tm .assert_series_equal (ser_compat , Series (result ))
186180
181+ @pytest .mark .parametrize ('zero' , zeros )
187182 def test_floordiv_zero (self , zero ):
188183 idx = self .create_index ()
189184 expected = Index ([np .nan , np .inf , np .inf , np .inf , np .inf ],
@@ -194,6 +189,7 @@ def test_floordiv_zero(self, zero):
194189 ser_compat = Series (idx ).astype ('i8' ) // np .array (zero ).astype ('i8' )
195190 tm .assert_series_equal (ser_compat , Series (result ))
196191
192+ @pytest .mark .parametrize ('zero' , zeros )
197193 def test_mod_zero (self , zero ):
198194 idx = self .create_index ()
199195
@@ -204,6 +200,7 @@ def test_mod_zero(self, zero):
204200 ser_compat = Series (idx ).astype ('i8' ) % np .array (zero ).astype ('i8' )
205201 tm .assert_series_equal (ser_compat , Series (result ))
206202
203+ @pytest .mark .parametrize ('zero' , zeros )
207204 def test_divmod_zero (self , zero ):
208205 idx = self .create_index ()
209206
0 commit comments