Skip to content

Commit

Permalink
Remove warnings in test_timedelta.py (#10418)
Browse files Browse the repository at this point in the history
Partially addresses #10363, by removing all warnings from `test_timedelta.py`.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #10418
  • Loading branch information
galipremsagar authored Mar 12, 2022
1 parent b1ea304 commit 2007480
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 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 @@ -622,7 +625,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 +816,7 @@ def test_timedelta_datetime_index_ops_misc(
),
],
)
@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()
Expand Down Expand Up @@ -872,6 +880,7 @@ def test_timedelta_index_ops_with_scalars(data, other_scalars, dtype, op):
),
],
)
@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()
Expand Down

0 comments on commit 2007480

Please sign in to comment.