Skip to content
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

[REVIEW] Remove warnings in test_timedelta.py #10418

Merged
merged 6 commits into from
Mar 12, 2022
Merged
Changes from 2 commits
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
16 changes: 13 additions & 3 deletions python/cudf/cudf/tests/test_timedelta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
# Copyright (c) 2020-2022, NVIDIA CORPORATION.

import datetime
import operator
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -450,6 +453,7 @@ def test_timedelta_dataframe_ops(df, op):
),
],
)
@pytest.mark.filterwarnings("ignore::RuntimeWarning")
galipremsagar marked this conversation as resolved.
Show resolved Hide resolved
def test_timedelta_series_ops_with_scalars(data, other_scalars, dtype, op):
gsr = cudf.Series(data=data, dtype=dtype)
psr = gsr.to_pandas()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -809,6 +817,7 @@ def test_timedelta_datetime_index_ops_misc(
),
],
)
@pytest.mark.filterwarnings("ignore::RuntimeWarning")
galipremsagar marked this conversation as resolved.
Show resolved Hide resolved
def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op):
gtdi = cudf.Index(data=data, dtype=dtype)
ptdi = gtdi.to_pandas()
Expand Down Expand Up @@ -872,6 +881,7 @@ def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op):
),
],
)
@pytest.mark.filterwarnings("ignore::RuntimeWarning")
galipremsagar marked this conversation as resolved.
Show resolved Hide resolved
def test_timedelta_index_ops_with_cudf_scalars(data, cpu_scalar, dtype, op):
gtdi = cudf.Index(data=data, dtype=dtype)
ptdi = gtdi.to_pandas()
Expand Down