From 3a2b9b9f6ad6474d6798af13c381f93e41b27e22 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 12 Apr 2022 16:37:23 -0700 Subject: [PATCH 1/2] Deprecate various functions that don't need to be defined for Index. --- python/cudf/cudf/core/frame.py | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index 1382ebfd8ee..ea679bcb2a6 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -917,6 +917,12 @@ def scatter_by_map( ------- A list of cudf.DataFrame objects. """ + if not isinstance(self, cudf.DataFrame): + warnings.warn( + f"{self.__class__}.scatter_by_map is deprecated and will be " + "removed.", + FutureWarning, + ) # map_index might be a column name or array, # make it a Column @@ -1095,6 +1101,8 @@ def fillna( elif method == "backfill": method = "bfill" + # TODO: This logic should be handled in different subclasses since + # different Frames support different types of values. if isinstance(value, cudf.Series): value = value.reindex(self._data.names) elif isinstance(value, cudf.DataFrame): @@ -1209,6 +1217,11 @@ def interpolate( some or all ``NaN`` values """ + if isinstance(self, cudf.BaseIndex): + warnings.warn( + "Index.interpolate is deprecated and will be removed.", + FutureWarning, + ) if method in {"pad", "ffill"} and limit_direction != "forward": raise ValueError( @@ -1320,6 +1333,12 @@ def rank( same type as caller Return a Series or DataFrame with data ranks as values. """ + if isinstance(self, cudf.BaseIndex): + warnings.warn( + "Index.rank is deprecated and will be removed.", + FutureWarning, + ) + if method not in {"average", "min", "max", "first", "dense"}: raise KeyError(method) @@ -1355,6 +1374,12 @@ def rank( @_cudf_nvtx_annotate def shift(self, periods=1, freq=None, axis=0, fill_value=None): """Shift values by `periods` positions.""" + if isinstance(self, cudf.BaseIndex): + warnings.warn( + "Index.shift is deprecated and will be removed.", + FutureWarning, + ) + axis = self._get_axis_from_axis_arg(axis) if axis != 0: raise ValueError("Only axis=0 is supported.") @@ -1747,6 +1772,12 @@ def replace( 3 3 8 d 4 4 9 e """ + if isinstance(self, cudf.BaseIndex): + warnings.warn( + "Index.replace is deprecated and will be removed.", + FutureWarning, + ) + if limit is not None: raise NotImplementedError("limit parameter is not implemented yet") @@ -2309,6 +2340,12 @@ def scale(self): 4 0.043478 dtype: float64 """ + if isinstance(self, cudf.BaseIndex): + warnings.warn( + "Index.scale is deprecated and will be removed.", + FutureWarning, + ) + vmin = self.min() vmax = self.max() scaled = (self - vmin) / (vmax - vmin) @@ -3357,6 +3394,12 @@ def _scan(self, op, axis=None, skipna=True): 2 6 24 3 10 34 """ + if isinstance(self, cudf.BaseIndex): + warnings.warn( + "This method is deprecated and will be removed.", + FutureWarning, + ) + cast_to_int = op in ("cumsum", "cumprod") skipna = True if skipna is None else skipna From c54dcdeb603443b2f0752722a758c807ff37a199 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 13 Apr 2022 14:24:58 -0700 Subject: [PATCH 2/2] Address PR reviews. --- python/cudf/cudf/core/frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index d233064f8d2..806cdf14c71 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -919,8 +919,8 @@ def scatter_by_map( """ if not isinstance(self, cudf.DataFrame): warnings.warn( - f"{self.__class__}.scatter_by_map is deprecated and will be " - "removed.", + f"{self.__class__.__name__}.scatter_by_map is deprecated and " + "will be removed.", FutureWarning, ) @@ -3404,7 +3404,7 @@ def _scan(self, op, axis=None, skipna=True): """ if isinstance(self, cudf.BaseIndex): warnings.warn( - "This method is deprecated and will be removed.", + f"Index.{op} is deprecated and will be removed.", FutureWarning, ) @@ -3445,7 +3445,7 @@ def _scan(self, op, axis=None, skipna=True): # TODO: This will work for Index because it's passing self._index # (which is None), but eventually we may want to remove that parameter # for Index._from_data and simplify. - return self._from_data(results, index=self._index) + return self._from_data(results, self._index) @_cudf_nvtx_annotate @ioutils.doc_to_json()