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

Fix warnings from pandas in test_array_ufunc.py. #10324

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Changes from 1 commit
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
29 changes: 27 additions & 2 deletions python/cudf/cudf/tests/test_array_ufunc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) 2020-2022, NVIDIA CORPORATION.

import operator
import warnings
from contextlib import contextmanager
from functools import reduce

import cupy as cp
Expand All @@ -17,6 +19,27 @@
]


@contextmanager
def _hide_ufunc_warnings(ufunc):
# pandas raises warnings for some inputs to the following ufuncs:
if ufunc.__name__ in {
"arccos",
"arccosh",
"arcsin",
"arctanh",
"fmod",
"log",
"log10",
"log2",
"reciprocal",
}:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=RuntimeWarning)
yield
else:
yield


@pytest.mark.parametrize("ufunc", _UFUNCS)
@pytest.mark.parametrize("has_nulls", [True, False])
@pytest.mark.parametrize("indexed", [True, False])
Expand Down Expand Up @@ -76,7 +99,8 @@ def test_ufunc_series(ufunc, has_nulls, indexed):
pytest.xfail(reason="Operation not supported by cupy")
raise

expect = ufunc(*(arg.to_pandas() for arg in pandas_args))
with _hide_ufunc_warnings(ufunc):
expect = ufunc(*(arg.to_pandas() for arg in pandas_args))

try:
if ufunc.nout > 1:
Expand Down Expand Up @@ -256,7 +280,8 @@ def test_ufunc_dataframe(ufunc, has_nulls, indexed):
pytest.xfail(reason="Operation not supported by cupy")
raise

expect = ufunc(*(arg.to_pandas() for arg in pandas_args))
with _hide_ufunc_warnings(ufunc):
expect = ufunc(*(arg.to_pandas() for arg in pandas_args))

try:
if ufunc.nout > 1:
Expand Down