From 81a80cff1ead6223cc0e8d32b573474f4eddc1d1 Mon Sep 17 00:00:00 2001 From: galipremsagar Date: Fri, 11 Mar 2022 12:12:42 -0800 Subject: [PATCH 1/4] remove all warnings --- python/cudf/cudf/tests/test_timedelta.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index 8c7fdfa5c39..d9c0a0a9ce8 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import datetime import operator @@ -109,7 +109,10 @@ def test_timedelta_from_typecast(data, dtype, cast_dtype): ) gsr = cudf.Series(data, dtype=dtype) - assert_eq(psr.astype(cast_dtype), gsr.astype(cast_dtype)) + if cast_dtype == "int64": + assert_eq(psr.values.view(cast_dtype), gsr.astype(cast_dtype).values) + else: + assert_eq(psr.astype(cast_dtype), gsr.astype(cast_dtype)) @pytest.mark.parametrize( @@ -450,6 +453,7 @@ def test_timedelta_dataframe_ops(df, op): ), ], ) +@pytest.mark.filterwarnings("ignore::RuntimeWarning") def test_timedelta_series_ops_with_scalars(data, other_scalars, dtype, op): gsr = cudf.Series(data=data, dtype=dtype) psr = gsr.to_pandas() @@ -622,7 +626,11 @@ def test_timedelta_reduction_ops(data, dtype, reduction_op): gsr = cudf.Series(data, dtype=dtype) psr = gsr.to_pandas() - expected = getattr(psr, reduction_op)() + if len(psr) > 0 and psr.isnull().all() and reduction_op == "median": + with pytest.warns(RuntimeWarning, match="Mean of empty slice"): + expected = getattr(psr, reduction_op)() + else: + expected = getattr(psr, reduction_op)() actual = getattr(gsr, reduction_op)() if pd.isna(expected) and pd.isna(actual): pass @@ -809,6 +817,7 @@ def test_timedelta_datetime_index_ops_misc( ), ], ) +@pytest.mark.filterwarnings("ignore::RuntimeWarning") def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op): gtdi = cudf.Index(data=data, dtype=dtype) ptdi = gtdi.to_pandas() @@ -872,6 +881,7 @@ def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op): ), ], ) +@pytest.mark.filterwarnings("ignore::RuntimeWarning") def test_timedelta_index_ops_with_cudf_scalars(data, cpu_scalar, dtype, op): gtdi = cudf.Index(data=data, dtype=dtype) ptdi = gtdi.to_pandas() From 39e8a4d369630c16bf9290a209168921d488be6b Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Fri, 11 Mar 2022 15:00:26 -0600 Subject: [PATCH 2/4] Update python/cudf/cudf/tests/test_timedelta.py Co-authored-by: Bradley Dice --- python/cudf/cudf/tests/test_timedelta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index d9c0a0a9ce8..d3bd9c299bf 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -817,7 +817,7 @@ def test_timedelta_datetime_index_ops_misc( ), ], ) -@pytest.mark.filterwarnings("ignore::RuntimeWarning") +@pytest.mark.filterwarnings("ignore:divide by zero:RuntimeWarning:pandas") def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op): gtdi = cudf.Index(data=data, dtype=dtype) ptdi = gtdi.to_pandas() From 61701dc3487dadd50c2b3fc190f4e89a36a00975 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Fri, 11 Mar 2022 15:09:06 -0600 Subject: [PATCH 3/4] Update python/cudf/cudf/tests/test_timedelta.py Co-authored-by: Bradley Dice --- python/cudf/cudf/tests/test_timedelta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index d3bd9c299bf..05fa526d8ed 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -881,7 +881,7 @@ def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op): ), ], ) -@pytest.mark.filterwarnings("ignore::RuntimeWarning") +@pytest.mark.filterwarnings("ignore:divide by zero:RuntimeWarning:pandas") def test_timedelta_index_ops_with_cudf_scalars(data, cpu_scalar, dtype, op): gtdi = cudf.Index(data=data, dtype=dtype) ptdi = gtdi.to_pandas() From 3c7b809007ebc1a578a6ae907135925305aecf5d Mon Sep 17 00:00:00 2001 From: galipremsagar Date: Fri, 11 Mar 2022 13:57:04 -0800 Subject: [PATCH 4/4] remove filter --- python/cudf/cudf/tests/test_timedelta.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index d9c0a0a9ce8..eafae94953e 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -453,7 +453,6 @@ def test_timedelta_dataframe_ops(df, op): ), ], ) -@pytest.mark.filterwarnings("ignore::RuntimeWarning") def test_timedelta_series_ops_with_scalars(data, other_scalars, dtype, op): gsr = cudf.Series(data=data, dtype=dtype) psr = gsr.to_pandas()