Skip to content

Commit

Permalink
fix and and tests for divmod
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Jan 22, 2018
1 parent 969f342 commit e0e89b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pandas/core/indexes/base.py
Expand Up @@ -4192,8 +4192,7 @@ def dispatch_missing(op, left, right, result):
result = missing.fill_zeros(result, left, right,
opstr, np.nan)
elif op is divmod:
res0 = missing.fill_zeros(result[0], left, right,
opstr, np.nan)
res0 = missing.mask_zero_div_zero(left, right, result[0])
res1 = missing.fill_zeros(result[1], left, right,
opstr, np.nan)
result = (res0, res1)
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/indexes/test_numeric.py
Expand Up @@ -197,6 +197,19 @@ def test_mod_zero(self, zero):
ser_compat = Series(idx).astype('i8') % np.array(zero).astype('i8')
tm.assert_series_equal(ser_compat, Series(result))

@pytest.mark.parametrize('zero', zeros)
def test_divmod_zero(self, zero):
idx = self.create_index()

exleft = Index([np.nan, np.inf, np.inf, np.inf, np.inf],
dtype=np.float64)
exright = Index([np.nan, np.nan, np.nan, np.nan, np.nan],
dtype=np.float64)

result = divmod(idx, zero)
tm.assert_index_equal(result[0], exleft)
tm.assert_index_equal(result[1], exright)

def test_explicit_conversions(self):

# GH 8608
Expand Down

0 comments on commit e0e89b9

Please sign in to comment.