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 in test_index.py #12313

Merged
merged 6 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
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
39 changes: 38 additions & 1 deletion python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ def copy(self, name=None, deep=False, dtype=None, names=None):
-------
New RangeIndex instance with same range, casted to new dtype
"""
if dtype is not None:
warnings.warn(
"parameter dtype is deprecated and will be removed in a "
"future version. Use the astype method instead.",
FutureWarning,
)

dtype = self.dtype if dtype is None else dtype

Expand Down Expand Up @@ -583,6 +589,16 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):

@_cudf_nvtx_annotate
def get_loc(self, key, method=None, tolerance=None):
# We should not actually remove this code until we have implemented the
# get_indexers method as an alternative, see
# https://github.com/rapidsai/cudf/issues/12312
if method is not None:
warnings.warn(
f"Passing method to {self.__class__.__name__}.get_loc is "
"deprecated and will raise in a future version.",
FutureWarning,
)

# Given an actual integer,
idx = (key - self._start) / self._step
idx_int_upper_bound = (self._stop - self._start) // self._step
Expand Down Expand Up @@ -1116,6 +1132,12 @@ def copy(self, name=None, deep=False, dtype=None, names=None):
-------
New index instance, casted to new dtype
"""
if dtype is not None:
warnings.warn(
"parameter dtype is deprecated and will be removed in a "
"future version. Use the astype method instead.",
FutureWarning,
)

dtype = self.dtype if dtype is None else dtype
name = self.name if name is None else name
Expand Down Expand Up @@ -1169,9 +1191,18 @@ def get_loc(self, key, method=None, tolerance=None):
>>> numeric_unique_index.get_loc(3)
2
"""
# We should not actually remove this code until we have implemented the
# get_indexers method as an alternative, see
# https://github.com/rapidsai/cudf/issues/12312
if method is not None:
warnings.warn(
f"Passing method to {self.__class__.__name__}.get_loc is "
"deprecated and will raise in a future version.",
FutureWarning,
)
if tolerance is not None:
raise NotImplementedError(
"Parameter tolerance is unsupported yet."
"Parameter tolerance is not supported yet."
)
if method not in {
None,
Expand Down Expand Up @@ -1555,6 +1586,12 @@ class NumericIndex(GenericIndex):

@_cudf_nvtx_annotate
def __init__(self, data=None, dtype=None, copy=False, name=None):
warnings.warn(
f"cudf.{self.__class__.__name__} is deprecated and will be "
"removed from cudf in a future version. Use cudf.Index with the "
"appropriate dtype instead.",
FutureWarning,
)

dtype = type(self)._dtype
if copy:
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ def get_loc(self, key, method=None, tolerance=None):
"""
if tolerance is not None:
raise NotImplementedError(
"Parameter tolerance is unsupported yet."
"Parameter tolerance is not supported yet."
)
if method is not None:
raise NotImplementedError(
Expand Down
Loading