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

Remove deprecated code for 23.02 #12281

Merged
merged 18 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 16 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
11 changes: 0 additions & 11 deletions python/cudf/cudf/_lib/copying.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2020-2022, NVIDIA CORPORATION.

import pickle
import warnings

from libc.stdint cimport int32_t, uint8_t, uintptr_t
from libcpp cimport bool
Expand Down Expand Up @@ -628,20 +627,10 @@ def shift(Column input, int offset, object fill_value=None):
cdef DeviceScalar fill

if isinstance(fill_value, DeviceScalar):
fill_value_type = fill_value.dtype
fill = fill_value
else:
fill_value_type = type(fill_value)
fill = as_device_scalar(fill_value, input.dtype)

if not cudf.utils.dtypes._can_cast(input.dtype, fill_value_type):
warnings.warn(
f"Passing {fill_value_type} to shift is deprecated and will "
f"raise in a future version"
f", pass a {input.dtype} scalar instead.",
FutureWarning,
)

cdef column_view c_input = input.view()
cdef int32_t c_offset = offset
cdef const scalar* c_fill_value = fill.get_raw_ptr()
Expand Down
50 changes: 4 additions & 46 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1922,30 +1922,13 @@ def _make_operands_and_index_for_binop(
],
Optional[BaseIndex],
]:
# Check built-in types first for speed.
if isinstance(other, (list, dict, abc.Sequence, abc.Mapping)):
warnings.warn(
"Binary operations between host objects such as "
f"{type(other)} and cudf.DataFrame are deprecated and will be "
"removed in a future release. Please convert it to a cudf "
"object before performing the operation.",
FutureWarning,
)
if len(other) != self._num_columns:
raise ValueError(
"Other is of the wrong length. Expected "
f"{self._num_columns}, got {len(other)}"
)

lhs, rhs = self._data, other
index = self._index
fill_requires_key = False
left_default: Any = False

if _is_scalar_or_zero_d_array(other):
rhs = {name: other for name in self._data}
elif isinstance(other, (list, abc.Sequence)):
rhs = {name: o for (name, o) in zip(self._data, other)}
elif isinstance(other, Series):
rhs = dict(zip(other.index.values_host, other.values_host))
# For keys in right but not left, perform binops between NaN (not
Expand All @@ -1972,6 +1955,10 @@ def _make_operands_and_index_for_binop(
# For DataFrame-DataFrame ops, always default to operating against
# the fill value.
left_default = fill_value
elif isinstance(other, (dict, abc.Mapping)):
# Need to fail early on host mapping types because we ultimately
# convert everything to a dict.
return NotImplemented, None

if not isinstance(rhs, (dict, abc.Mapping)):
return NotImplemented, None
Expand Down Expand Up @@ -5566,35 +5553,6 @@ def quantile(
result.index = list(map(float, qs))
return result

@_cudf_nvtx_annotate
def quantiles(self, q=0.5, interpolation="nearest"):
"""
Return values at the given quantile.

This API is now deprecated. Please use ``DataFrame.quantile``
with ``method='table'``.

Parameters
----------
q : float or array-like
0 <= q <= 1, the quantile(s) to compute
interpolation : {`lower`, `higher`, `nearest`}
This parameter specifies the interpolation method to use,
when the desired quantile lies between two data points i and j.
Default 'nearest'.

Returns
-------
DataFrame
"""
warnings.warn(
"DataFrame.quantiles is now deprecated. "
"Please use DataFrame.quantile with `method='table'`.",
FutureWarning,
)

return self.quantile(q=q, interpolation=interpolation, method="table")

@_cudf_nvtx_annotate
def isin(self, values):
"""
Expand Down
14 changes: 2 additions & 12 deletions python/cudf/cudf/core/indexed_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,6 @@ 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")

Expand Down Expand Up @@ -3325,6 +3319,8 @@ def repeat(self, repeats, axis=None):
def _append(
self, other, ignore_index=False, verify_integrity=False, sort=None
):
# Note: Do not remove this function until pandas does. This warning is
# to clean up cudf but to match a deprecation in pandas
warnings.warn(
"The append method is deprecated and will be removed in a future "
"version. Use cudf.concat instead.",
Expand Down Expand Up @@ -4679,12 +4675,6 @@ 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)

Expand Down
24 changes: 6 additions & 18 deletions python/cudf/cudf/core/single_column_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

from __future__ import annotations

import warnings
from typing import Any, Dict, Optional, Tuple, TypeVar, Union

import cupy
import numpy as np
import pandas as pd

import cudf
from cudf._typing import Dtype, NotImplementedType, ScalarLike
Expand Down Expand Up @@ -326,29 +324,19 @@ def _make_operands_for_binop(
# Get the appropriate name for output operations involving two objects
# that are Series-like objects. The output shares the lhs's name unless
# the rhs is a _differently_ named Series-like object.
if (
isinstance(other, (SingleColumnFrame, pd.Series, pd.Index))
and self.name != other.name
):
if isinstance(other, SingleColumnFrame) and self.name != other.name:
result_name = None
else:
result_name = self.name

# TODO: This needs to be tested correctly
if isinstance(other, SingleColumnFrame):
other = other._column
elif not _is_scalar_or_zero_d_array(other):
if not hasattr(other, "__cuda_array_interface__"):
# TODO: When this deprecated behavior is removed, also change
# the above conditional to stop checking for pd.Series and
# pd.Index since we only need to support SingleColumnFrame.
warnings.warn(
f"Binary operations between host objects such as "
f"{type(other)} and {type(self)} are deprecated and will "
"be removed in a future release. Please convert it to a "
"cudf object before performing the operation.",
FutureWarning,
)
if not hasattr(
other, "__cuda_array_interface__"
) and not isinstance(other, cudf.RangeIndex):
return NotImplemented

# Non-scalar right operands are valid iff they convert to columns.
try:
other = as_column(other)
Expand Down
19 changes: 4 additions & 15 deletions python/cudf/cudf/io/avro.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright (c) 2019-2022, NVIDIA CORPORATION.

import warnings

import cudf
from cudf import _lib as libcudf
from cudf.utils import ioutils
Expand All @@ -10,7 +8,6 @@
@ioutils.doc_read_avro()
vyasr marked this conversation as resolved.
Show resolved Hide resolved
def read_avro(
filepath_or_buffer,
engine="cudf",
columns=None,
skiprows=None,
num_rows=None,
Expand All @@ -35,16 +32,8 @@ def read_avro(
if compression is not None:
ValueError("URL content-encoding decompression is not supported")

if engine == "cudf":
warnings.warn(
"The `engine` parameter is deprecated and will be removed in a "
"future release",
FutureWarning,
)
return cudf.DataFrame._from_data(
*libcudf.avro.read_avro(
filepath_or_buffer, columns, skiprows, num_rows
)
return cudf.DataFrame._from_data(
*libcudf.avro.read_avro(
filepath_or_buffer, columns, skiprows, num_rows
)
else:
raise NotImplementedError("read_avro currently only supports cudf")
)
24 changes: 9 additions & 15 deletions python/cudf/cudf/tests/test_array_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,15 @@ def test_ufunc_index(ufunc):
@pytest.mark.parametrize(
"ufunc", [np.add, np.greater, np.greater_equal, np.logical_and]
)
@pytest.mark.parametrize("type_", ["cupy", "numpy", "list"])
@pytest.mark.parametrize("reflect", [True, False])
def test_binary_ufunc_index_array(ufunc, type_, reflect):
def test_binary_ufunc_index_array(ufunc, reflect):
N = 100
# Avoid zeros in either array to skip division by 0 errors. Also limit the
# scale to avoid issues with overflow, etc. We use ints because some
# operations (like bitwise ops) are not defined for floats.
args = [cudf.Index(cp.random.rand(N)) for _ in range(ufunc.nin)]

arg1 = args[1].to_cupy() if type_ == "cupy" else args[1].to_numpy()
if type_ == "list":
arg1 = arg1.tolist()
arg1 = args[1].to_cupy()

if reflect:
got = ufunc(arg1, args[0])
Expand All @@ -126,12 +123,12 @@ def test_binary_ufunc_index_array(ufunc, type_, reflect):

if ufunc.nout > 1:
for g, e in zip(got, expect):
if type_ == "cupy" and reflect:
if reflect:
assert (cp.asnumpy(g) == e).all()
else:
assert_eq(g, e, check_exact=False)
else:
if type_ == "cupy" and reflect:
if reflect:
assert (cp.asnumpy(got) == expect).all()
else:
assert_eq(got, expect, check_exact=False)
Expand Down Expand Up @@ -226,16 +223,15 @@ def test_ufunc_series(ufunc, has_nulls, indexed):
)
@pytest.mark.parametrize("has_nulls", [True, False])
@pytest.mark.parametrize("indexed", [True, False])
@pytest.mark.parametrize("type_", ["cupy", "numpy", "list"])
@pytest.mark.parametrize("reflect", [True, False])
def test_binary_ufunc_series_array(ufunc, has_nulls, indexed, type_, reflect):
def test_binary_ufunc_series_array(ufunc, has_nulls, indexed, reflect):
fname = ufunc.__name__
if fname in ("greater", "greater_equal", "logical_and") and has_nulls:
pytest.xfail(
"The way cudf casts nans in arrays to nulls during binops with "
"cudf objects is currently incompatible with pandas."
)
if reflect and has_nulls and type_ == "cupy":
if reflect and has_nulls:
pytest.skip(
"When cupy is the left operand there is no way for us to avoid "
"calling its binary operators, which cannot handle cudf objects "
Expand Down Expand Up @@ -264,9 +260,7 @@ def test_binary_ufunc_series_array(ufunc, has_nulls, indexed, type_, reflect):
args[1] = args[1].fillna(cp.nan)
mask = args[0].isna().to_pandas()

arg1 = args[1].to_cupy() if type_ == "cupy" else args[1].to_numpy()
if type_ == "list":
arg1 = arg1.tolist()
arg1 = args[1].to_cupy()

if reflect:
got = ufunc(arg1, args[0])
Expand All @@ -279,14 +273,14 @@ def test_binary_ufunc_series_array(ufunc, has_nulls, indexed, type_, reflect):
for g, e in zip(got, expect):
if has_nulls:
e[mask] = np.nan
if type_ == "cupy" and reflect:
if reflect:
assert (cp.asnumpy(g) == e).all()
else:
assert_eq(g, e, check_exact=False)
else:
if has_nulls:
expect[mask] = np.nan
if type_ == "cupy" and reflect:
if reflect:
assert (cp.asnumpy(got) == expect).all()
else:
assert_eq(got, expect, check_exact=False)
Expand Down
5 changes: 2 additions & 3 deletions python/cudf/cudf/tests/test_binops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3101,12 +3101,11 @@ def test_add_series_to_dataframe():

@pytest.mark.parametrize("obj_class", [cudf.Series, cudf.Index])
@pytest.mark.parametrize("binop", _binops)
@pytest.mark.parametrize("other_type", [np.array, cp.array, pd.Series, list])
def test_binops_non_cudf_types(obj_class, binop, other_type):
def test_binops_cupy_array(obj_class, binop):
# Skip 0 to not deal with NaNs from division.
data = range(1, 100)
lhs = obj_class(data)
rhs = other_type(data)
rhs = cp.array(data)
assert (binop(lhs, rhs) == binop(lhs, lhs)).all()


Expand Down
Loading