Skip to content

DEPR: Remove DeprecationWarnings #50648

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

Merged
merged 3 commits into from
Jan 10, 2023
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
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,8 @@ Removal of prior version deprecations/changes
- Removed the deprecated argument ``line_terminator`` from :meth:`DataFrame.to_csv` (:issue:`45302`)
- Removed the deprecated argument ``label`` from :func:`lreshape` (:issue:`30219`)
- Arguments after ``expr`` in :meth:`DataFrame.eval` and :meth:`DataFrame.query` are keyword-only (:issue:`47587`)
-
- Removed :meth:`Index._get_attributes_dict` (:issue:`50648`)
- Removed :meth:`Series.__array_wrap__` (:issue:`50648`)

.. ---------------------------------------------------------------------------
.. _whatsnew_200.performance:
Expand Down
37 changes: 0 additions & 37 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2009,43 +2009,6 @@ def empty(self) -> bool_t:
def __array__(self, dtype: npt.DTypeLike | None = None) -> np.ndarray:
return np.asarray(self._values, dtype=dtype)

def __array_wrap__(
self,
result: np.ndarray,
context: tuple[Callable, tuple[Any, ...], int] | None = None,
):
"""
Gets called after a ufunc and other functions.

Parameters
----------
result: np.ndarray
The result of the ufunc or other function called on the NumPy array
returned by __array__
context: tuple of (func, tuple, int)
This parameter is returned by ufuncs as a 3-element tuple: (name of the
ufunc, arguments of the ufunc, domain of the ufunc), but is not set by
other numpy functions.q

Notes
-----
Series implements __array_ufunc_ so this not called for ufunc on Series.
"""
# Note: at time of dask 2022.01.0, this is still used by dask
warnings.warn(
"The __array_wrap__ method of DataFrame and Series will be removed in "
"a future version",
DeprecationWarning,
stacklevel=find_stack_level(),
)
res = lib.item_from_zerodim(result)
if is_scalar(res):
# e.g. we get here with np.ptp(series)
# ptp also requires the item_from_zerodim
return res
d = self._construct_axes_dict(self._AXIS_ORDERS, copy=False)
return self._constructor(res, **d).__finalize__(self, method="__array_wrap__")

@final
def __array_ufunc__(
self, ufunc: np.ufunc, method: str, *inputs: Any, **kwargs: Any
Expand Down
16 changes: 0 additions & 16 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,22 +698,6 @@ def _format_duplicate_message(self) -> DataFrame:
# --------------------------------------------------------------------
# Index Internals Methods

@final
def _get_attributes_dict(self) -> dict[str_t, Any]:
"""
Return an attributes dict for my class.

Temporarily added back for compatibility issue in dask, see
https://github.com/pandas-dev/pandas/pull/43895
"""
warnings.warn(
"The Index._get_attributes_dict method is deprecated, and will be "
"removed in a future version",
DeprecationWarning,
stacklevel=find_stack_level(),
)
return {k: getattr(self, k, None) for k in self._attributes}

def _shallow_copy(self: _IndexT, values, name: Hashable = no_default) -> _IndexT:
"""
Create a new Index with the same class as the caller, don't copy the
Expand Down
11 changes: 0 additions & 11 deletions pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@ def test_ndarray_compat_properties(index_or_series_obj):
assert Series([1]).item() == 1


def test_array_wrap_compat():
# Note: at time of dask 2022.01.0, this is still used by eg dask
# (https://github.com/dask/dask/issues/8580).
# This test is a small dummy ensuring coverage
orig = Series([1, 2, 3], dtype="int64", index=["a", "b", "c"])
with tm.assert_produces_warning(DeprecationWarning):
result = orig.__array_wrap__(np.array([2, 4, 6], dtype="int64"))
expected = orig * 2
tm.assert_series_equal(result, expected)


@pytest.mark.skipif(PYPY, reason="not relevant for PyPy")
def test_memory_usage(index_or_series_obj):
obj = index_or_series_obj
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,14 +1605,6 @@ def test_construct_from_memoryview(klass, extra_kwargs):
tm.assert_index_equal(result, expected, exact=True)


def test_get_attributes_dict_deprecated():
# https://github.com/pandas-dev/pandas/pull/44028
idx = Index([1, 2, 3, 1])
with tm.assert_produces_warning(DeprecationWarning):
attrs = idx._get_attributes_dict()
assert attrs == {"name": None}


@pytest.mark.parametrize("op", [operator.lt, operator.gt])
def test_nan_comparison_same_object(op):
# GH#47105
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ def test_dask(df):
pd.set_option("compute.use_numexpr", olduse)


@pytest.mark.filterwarnings("ignore:The __array_wrap__:DeprecationWarning")
def test_dask_ufunc():
# At the time of dask 2022.01.0, dask is still directly using __array_wrap__
# for some ufuncs (https://github.com/dask/dask/issues/8580).

# dask sets "compute.use_numexpr" to False, so catch the current value
# and ensure to reset it afterwards to avoid impacting other tests
olduse = pd.get_option("compute.use_numexpr")
Expand Down