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

Deprecate cudf.isclose #17351

Open
wants to merge 1 commit into
base: branch-25.02
Choose a base branch
from
Open
Changes from all 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
23 changes: 23 additions & 0 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -5322,6 +5322,29 @@ def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False):
5 False
dtype: bool
"""
warnings.warn(
"`cudf.close` is deprecated and will be removed in a future version of cudf. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"`cudf.close` is deprecated and will be removed in a future version of cudf. "
"`cudf.isclose` is deprecated and will be removed in a future version of cudf. "

'''
import cupy as cp
import pandas as pd
from cudf.core.column import (
as_column,
)

a = pd.array([1.0, 2.0, None])
b = pd.array([1.0, 2.1, None])

a_col = as_column(a)
a_array = cupy.asarray(a_col.data_array_view(mode="read"))

b_col = as_column(b)
b_array = cupy.asarray(b_col.data_array_view(mode="read"))

result = cp.isclose(a, b, equal_nan=True)
print(result) # Output: [ True False True]
''',
Comment on lines +5327 to +5345
Copy link
Contributor

@bdice bdice Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We noted in #13593: "As part of the deprecation, we decided to add a warning message indicating how to support nulls while using cupy.isclose." However, I am not sure if this is the right code snippet.

The code we want to give to the user as a replacement for this deprecated code path is essentially the current implementation in this method. Basically it has two steps:

  • Call cupy.isclose to see if the values are "close" to each other. This does not account for null values in the input.
  • Compare the null masks of each input. If equal_nan is False, we mark all null values as False ("not close") in the result. If equal_nan is True, we set the values where one column's input is null as False and the values where both columns' input are null as True.

I would suggest we add this snippet to the page "Working with missing data": https://docs.rapids.ai/api/cudf/stable/user_guide/missing-data/

Then we can link to this snippet in the docs from the deprecated method's docstring and in the deprecation warning.

Does that make sense? Let me know if you have questions.

FutureWarning
)

if not can_convert_to_column(a):
raise TypeError(
Expand Down
Loading