@@ -265,25 +265,11 @@ def test_divmod_zero(self, zero, numeric_idx):
265
265
266
266
# ------------------------------------------------------------------
267
267
268
- @pytest .mark .parametrize (
269
- "dtype2" ,
270
- [
271
- np .int64 ,
272
- np .int32 ,
273
- np .int16 ,
274
- np .int8 ,
275
- np .float64 ,
276
- np .float32 ,
277
- np .float16 ,
278
- np .uint64 ,
279
- np .uint32 ,
280
- np .uint16 ,
281
- np .uint8 ,
282
- ],
283
- )
284
268
@pytest .mark .parametrize ("dtype1" , [np .int64 , np .float64 , np .uint64 ])
285
- def test_ser_div_ser (self , dtype1 , dtype2 ):
269
+ def test_ser_div_ser (self , dtype1 , any_real_dtype ):
286
270
# no longer do integer div for any ops, but deal with the 0's
271
+ dtype2 = any_real_dtype
272
+
287
273
first = Series ([3 , 4 , 5 , 8 ], name = "first" ).astype (dtype1 )
288
274
second = Series ([0 , 0 , 0 , 3 ], name = "second" ).astype (dtype2 )
289
275
@@ -299,6 +285,39 @@ def test_ser_div_ser(self, dtype1, dtype2):
299
285
tm .assert_series_equal (result , expected )
300
286
assert not result .equals (second / first )
301
287
288
+ @pytest .mark .parametrize ("dtype1" , [np .int64 , np .float64 , np .uint64 ])
289
+ def test_ser_divmod_zero (self , dtype1 , any_real_dtype ):
290
+ # GH#26987
291
+ dtype2 = any_real_dtype
292
+ left = pd .Series ([1 , 1 ]).astype (dtype1 )
293
+ right = pd .Series ([0 , 2 ]).astype (dtype2 )
294
+
295
+ expected = left // right , left % right
296
+ result = divmod (left , right )
297
+
298
+ tm .assert_series_equal (result [0 ], expected [0 ])
299
+ tm .assert_series_equal (result [1 ], expected [1 ])
300
+
301
+ # rdivmod case
302
+ result = divmod (left .values , right )
303
+ tm .assert_series_equal (result [0 ], expected [0 ])
304
+ tm .assert_series_equal (result [1 ], expected [1 ])
305
+
306
+ def test_ser_divmod_inf (self ):
307
+ left = pd .Series ([np .inf , 1.0 ])
308
+ right = pd .Series ([np .inf , 2.0 ])
309
+
310
+ expected = left // right , left % right
311
+ result = divmod (left , right )
312
+
313
+ tm .assert_series_equal (result [0 ], expected [0 ])
314
+ tm .assert_series_equal (result [1 ], expected [1 ])
315
+
316
+ # rdivmod case
317
+ result = divmod (left .values , right )
318
+ tm .assert_series_equal (result [0 ], expected [0 ])
319
+ tm .assert_series_equal (result [1 ], expected [1 ])
320
+
302
321
def test_rdiv_zero_compat (self ):
303
322
# GH#8674
304
323
zero_array = np .array ([0 ] * 5 )
@@ -662,7 +681,9 @@ def test_modulo2(self):
662
681
result2 = p ["second" ] % p ["first" ]
663
682
assert not result .equals (result2 )
664
683
665
- # GH#9144
684
+ def test_modulo_zero_int (self ):
685
+ # GH#9144
686
+ with np .errstate (all = "ignore" ):
666
687
s = Series ([0 , 1 ])
667
688
668
689
result = s % 0
0 commit comments