Skip to content

~Finish collecting m8[ns] tests, start collecting division by zero tests #22153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
port test_td64arr_rfloordiv_tdlike_scalar
  • Loading branch information
jbrockmendel committed Aug 1, 2018
commit 9ee6d0f21062b636cf34cd49236672a36974682e
20 changes: 0 additions & 20 deletions pandas/tests/indexes/timedeltas/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,26 +220,6 @@ def test_tdi_div_nat_raises(self):
with pytest.raises(TypeError):
rng / pd.NaT

# -------------------------------------------------------------
# TimedeltaIndex.__floordiv__

@pytest.mark.parametrize('scalar_td', [
timedelta(minutes=10, seconds=7),
Timedelta('10m7s'),
Timedelta('10m7s').to_timedelta64()])
def test_tdi_floordiv_timedelta_scalar(self, scalar_td):
# GH#19125
tdi = TimedeltaIndex(['00:05:03', '00:05:03', pd.NaT], freq=None)
expected = pd.Index([2.0, 2.0, np.nan])

res = tdi.__rfloordiv__(scalar_td)
tm.assert_index_equal(res, expected)

expected = pd.Index([0.0, 0.0, np.nan])

res = tdi // (scalar_td)
tm.assert_index_equal(res, expected)


class TestTimedeltaIndexArithmetic(object):
# Addition and Subtraction Operations
Expand Down
25 changes: 25 additions & 0 deletions pandas/tests/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def box(request):
"""
return request.param


@pytest.fixture(params=[
pd.Index,
Series,
Expand Down Expand Up @@ -612,6 +613,30 @@ def test_td64arr_floordiv_tdlike_scalar(self, delta, box_df_fail):
result = tdi // delta
tm.assert_equal(result, expected)

# TODO: Is this redundant with test_td64arr_floordiv_tdlike_scalar?
@pytest.mark.parametrize('scalar_td', [
timedelta(minutes=10, seconds=7),
Timedelta('10m7s'),
Timedelta('10m7s').to_timedelta64()
], ids=lambda x: type(x).__name__)
def test_td64arr_rfloordiv_tdlike_scalar(self, scalar_td, box_df_fail):
# GH#19125
box = box_df_fail # DataFrame op returns m8[ns] instead of f8 dtype
tdi = TimedeltaIndex(['00:05:03', '00:05:03', pd.NaT], freq=None)
expected = pd.Index([2.0, 2.0, np.nan])

tdi = tm.box_expected(tdi, box)
expected = tm.box_expected(expected, box)

res = tdi.__rfloordiv__(scalar_td)
tm.assert_equal(res, expected)

expected = pd.Index([0.0, 0.0, np.nan])
expected = tm.box_expected(expected, box)

res = tdi // (scalar_td)
tm.assert_equal(res, expected)

# ------------------------------------------------------------------
# Operations with invalid others

Expand Down