From f06a6b96737a5326732c05247031c4df4c39c186 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Fri, 11 Nov 2022 09:06:55 +0000 Subject: [PATCH] Remove xfails related to #5938 --- python/cudf/cudf/tests/test_timedelta.py | 75 ++++++++++++++++++++---- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index 23270875a92..84b7d4a1984 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -400,12 +400,7 @@ def test_timedelta_dataframe_ops(df, op): [1], [12, 11, 232, 223432411, 2343241, 234324, 23234], [12, 11, 2.32, 2234.32411, 2343.241, 23432.4, 23234], - pytest.param( - [1.321, 1132.324, 23223231.11, 233.41, 0.2434, 332, 323], - marks=pytest.mark.xfail( - reason="https://github.com/rapidsai/cudf/issues/5938" - ), - ), + [1.321, 1132.324, 23223231.11, 233.41, 332, 323], [12, 11, 2.32, 2234.32411, 2343.241, 23432.4, 23234], ], ) @@ -492,6 +487,36 @@ def test_timedelta_series_ops_with_scalars(data, other_scalars, dtype, op): assert_eq(expected, actual) +@pytest.mark.parametrize( + "reverse", + [ + False, + pytest.param( + True, + marks=pytest.mark.xfail( + strict=True, + reason=( + "timedelta modulo by zero is dubiously defined in " + "both pandas and cuDF " + "(see https://github.com/rapidsai/cudf/issues/5938)" + ), + ), + ), + ], +) +def test_timedelta_series_mod_with_scalar_zero(reverse): + gsr = cudf.Series(data=[0.2434], dtype=np.timedelta64(1, "ns")) + psr = gsr.to_pandas() + scalar = datetime.timedelta(days=768) + if reverse: + expected = scalar % psr + actual = scalar % gsr + else: + expected = psr % scalar + actual = gsr % scalar + assert_eq(expected, actual) + + @pytest.mark.parametrize( "data", [ @@ -597,6 +622,37 @@ def test_timedelta_series_ops_with_cudf_scalars(data, cpu_scalar, dtype, op): assert_eq(expected, actual) +@pytest.mark.parametrize( + "reverse", + [ + False, + pytest.param( + True, + marks=pytest.mark.xfail( + strict=True, + reason=( + "timedelta modulo by zero is dubiously defined in " + "both pandas and cuDF " + "(see https://github.com/rapidsai/cudf/issues/5938)" + ), + ), + ), + ], +) +def test_timedelta_series_mod_with_cudf_scalar_zero(reverse): + gsr = cudf.Series(data=[0.2434], dtype=np.timedelta64(1, "ns")) + psr = gsr.to_pandas() + scalar = datetime.timedelta(days=768) + gpu_scalar = cudf.Scalar(scalar) + if reverse: + expected = scalar % psr + actual = gpu_scalar % gsr + else: + expected = psr % scalar + actual = gsr % gpu_scalar + assert_eq(expected, actual) + + @pytest.mark.parametrize( "data", [ @@ -873,12 +929,7 @@ def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op): "add", "sub", "truediv", - pytest.param( - "floordiv", - marks=pytest.mark.xfail( - reason="https://github.com/rapidsai/cudf/issues/5938" - ), - ), + "floordiv", ], ) @pytest.mark.filterwarnings("ignore:divide by zero:RuntimeWarning:pandas")