From acbc165e164da86e61bcd3070ec2eff28a9432ed Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Sun, 18 Oct 2020 11:52:23 +0700 Subject: [PATCH 1/3] CLN: de-duplicate in test_numeric --- pandas/tests/arithmetic/test_numeric.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pandas/tests/arithmetic/test_numeric.py b/pandas/tests/arithmetic/test_numeric.py index 04ba41307d0ef..bf57b3a7b2597 100644 --- a/pandas/tests/arithmetic/test_numeric.py +++ b/pandas/tests/arithmetic/test_numeric.py @@ -172,20 +172,12 @@ def test_div_td64arr(self, left, box_cls): with pytest.raises(TypeError, match=msg): left // right - # TODO: de-duplicate with test_numeric_arr_mul_tdscalar - def test_ops_series(self): - # regression test for G#H8813 - td = Timedelta("1 day") - other = pd.Series([1, 2]) - expected = pd.Series(pd.to_timedelta(["1 day", "2 days"])) - tm.assert_series_equal(expected, td * other) - tm.assert_series_equal(expected, other * td) - # TODO: also test non-nanosecond timedelta64 and Tick objects; # see test_numeric_arr_rdiv_tdscalar for note on these failing @pytest.mark.parametrize( "scalar_td", [ + Timedelta("1 day"), Timedelta(days=1), Timedelta(days=1).to_timedelta64(), Timedelta(days=1).to_pytimedelta(), @@ -196,7 +188,7 @@ def test_numeric_arr_mul_tdscalar(self, scalar_td, numeric_idx, box_with_array): # GH#19333 box = box_with_array index = numeric_idx - expected = pd.TimedeltaIndex([pd.Timedelta(days=n) for n in range(5)]) + expected = pd.TimedeltaIndex([pd.Timedelta(days=n) for n in range(len(index))]) index = tm.box_expected(index, box) expected = tm.box_expected(expected, box) From 8ed35d22235ede6761ed7848574c6b1bebcb3083 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Sun, 18 Oct 2020 12:09:59 +0700 Subject: [PATCH 2/3] TST: test non-nanosecond timedelta64 --- pandas/tests/arithmetic/test_numeric.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/arithmetic/test_numeric.py b/pandas/tests/arithmetic/test_numeric.py index bf57b3a7b2597..c50adecc0d952 100644 --- a/pandas/tests/arithmetic/test_numeric.py +++ b/pandas/tests/arithmetic/test_numeric.py @@ -172,7 +172,7 @@ def test_div_td64arr(self, left, box_cls): with pytest.raises(TypeError, match=msg): left // right - # TODO: also test non-nanosecond timedelta64 and Tick objects; + # TODO: also test Tick objects; # see test_numeric_arr_rdiv_tdscalar for note on these failing @pytest.mark.parametrize( "scalar_td", @@ -181,6 +181,8 @@ def test_div_td64arr(self, left, box_cls): Timedelta(days=1), Timedelta(days=1).to_timedelta64(), Timedelta(days=1).to_pytimedelta(), + Timedelta(days=1).to_timedelta64().astype("timedelta64[s]"), + Timedelta(days=1).to_timedelta64().astype("timedelta64[ms]"), ], ids=lambda x: type(x).__name__, ) From 5553cd80a21199973703eb9de3b8981b21045ff4 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Mon, 19 Oct 2020 12:23:37 +0700 Subject: [PATCH 3/3] TST: drop redundant case --- pandas/tests/arithmetic/test_numeric.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/arithmetic/test_numeric.py b/pandas/tests/arithmetic/test_numeric.py index c50adecc0d952..b5f14700088bb 100644 --- a/pandas/tests/arithmetic/test_numeric.py +++ b/pandas/tests/arithmetic/test_numeric.py @@ -177,7 +177,6 @@ def test_div_td64arr(self, left, box_cls): @pytest.mark.parametrize( "scalar_td", [ - Timedelta("1 day"), Timedelta(days=1), Timedelta(days=1).to_timedelta64(), Timedelta(days=1).to_pytimedelta(),