Skip to content

Commit 5535def

Browse files
authored
DEPR: Remove DeprecationWarnings (#50648)
1 parent 939d0ba commit 5535def

File tree

6 files changed

+2
-77
lines changed

6 files changed

+2
-77
lines changed

doc/source/whatsnew/v2.0.0.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ Removal of prior version deprecations/changes
790790
- Removed the deprecated argument ``line_terminator`` from :meth:`DataFrame.to_csv` (:issue:`45302`)
791791
- Removed the deprecated argument ``label`` from :func:`lreshape` (:issue:`30219`)
792792
- Arguments after ``expr`` in :meth:`DataFrame.eval` and :meth:`DataFrame.query` are keyword-only (:issue:`47587`)
793-
-
793+
- Removed :meth:`Index._get_attributes_dict` (:issue:`50648`)
794+
- Removed :meth:`Series.__array_wrap__` (:issue:`50648`)
794795

795796
.. ---------------------------------------------------------------------------
796797
.. _whatsnew_200.performance:

pandas/core/generic.py

-37
Original file line numberDiff line numberDiff line change
@@ -2009,43 +2009,6 @@ def empty(self) -> bool_t:
20092009
def __array__(self, dtype: npt.DTypeLike | None = None) -> np.ndarray:
20102010
return np.asarray(self._values, dtype=dtype)
20112011

2012-
def __array_wrap__(
2013-
self,
2014-
result: np.ndarray,
2015-
context: tuple[Callable, tuple[Any, ...], int] | None = None,
2016-
):
2017-
"""
2018-
Gets called after a ufunc and other functions.
2019-
2020-
Parameters
2021-
----------
2022-
result: np.ndarray
2023-
The result of the ufunc or other function called on the NumPy array
2024-
returned by __array__
2025-
context: tuple of (func, tuple, int)
2026-
This parameter is returned by ufuncs as a 3-element tuple: (name of the
2027-
ufunc, arguments of the ufunc, domain of the ufunc), but is not set by
2028-
other numpy functions.q
2029-
2030-
Notes
2031-
-----
2032-
Series implements __array_ufunc_ so this not called for ufunc on Series.
2033-
"""
2034-
# Note: at time of dask 2022.01.0, this is still used by dask
2035-
warnings.warn(
2036-
"The __array_wrap__ method of DataFrame and Series will be removed in "
2037-
"a future version",
2038-
DeprecationWarning,
2039-
stacklevel=find_stack_level(),
2040-
)
2041-
res = lib.item_from_zerodim(result)
2042-
if is_scalar(res):
2043-
# e.g. we get here with np.ptp(series)
2044-
# ptp also requires the item_from_zerodim
2045-
return res
2046-
d = self._construct_axes_dict(self._AXIS_ORDERS, copy=False)
2047-
return self._constructor(res, **d).__finalize__(self, method="__array_wrap__")
2048-
20492012
@final
20502013
def __array_ufunc__(
20512014
self, ufunc: np.ufunc, method: str, *inputs: Any, **kwargs: Any

pandas/core/indexes/base.py

-16
Original file line numberDiff line numberDiff line change
@@ -698,22 +698,6 @@ def _format_duplicate_message(self) -> DataFrame:
698698
# --------------------------------------------------------------------
699699
# Index Internals Methods
700700

701-
@final
702-
def _get_attributes_dict(self) -> dict[str_t, Any]:
703-
"""
704-
Return an attributes dict for my class.
705-
706-
Temporarily added back for compatibility issue in dask, see
707-
https://github.com/pandas-dev/pandas/pull/43895
708-
"""
709-
warnings.warn(
710-
"The Index._get_attributes_dict method is deprecated, and will be "
711-
"removed in a future version",
712-
DeprecationWarning,
713-
stacklevel=find_stack_level(),
714-
)
715-
return {k: getattr(self, k, None) for k in self._attributes}
716-
717701
def _shallow_copy(self: _IndexT, values, name: Hashable = no_default) -> _IndexT:
718702
"""
719703
Create a new Index with the same class as the caller, don't copy the

pandas/tests/base/test_misc.py

-11
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@ def test_ndarray_compat_properties(index_or_series_obj):
8484
assert Series([1]).item() == 1
8585

8686

87-
def test_array_wrap_compat():
88-
# Note: at time of dask 2022.01.0, this is still used by eg dask
89-
# (https://github.com/dask/dask/issues/8580).
90-
# This test is a small dummy ensuring coverage
91-
orig = Series([1, 2, 3], dtype="int64", index=["a", "b", "c"])
92-
with tm.assert_produces_warning(DeprecationWarning):
93-
result = orig.__array_wrap__(np.array([2, 4, 6], dtype="int64"))
94-
expected = orig * 2
95-
tm.assert_series_equal(result, expected)
96-
97-
9887
@pytest.mark.skipif(PYPY, reason="not relevant for PyPy")
9988
def test_memory_usage(index_or_series_obj):
10089
obj = index_or_series_obj

pandas/tests/indexes/test_base.py

-8
Original file line numberDiff line numberDiff line change
@@ -1605,14 +1605,6 @@ def test_construct_from_memoryview(klass, extra_kwargs):
16051605
tm.assert_index_equal(result, expected, exact=True)
16061606

16071607

1608-
def test_get_attributes_dict_deprecated():
1609-
# https://github.com/pandas-dev/pandas/pull/44028
1610-
idx = Index([1, 2, 3, 1])
1611-
with tm.assert_produces_warning(DeprecationWarning):
1612-
attrs = idx._get_attributes_dict()
1613-
assert attrs == {"name": None}
1614-
1615-
16161608
@pytest.mark.parametrize("op", [operator.lt, operator.gt])
16171609
def test_nan_comparison_same_object(op):
16181610
# GH#47105

pandas/tests/test_downstream.py

-4
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ def test_dask(df):
5858
pd.set_option("compute.use_numexpr", olduse)
5959

6060

61-
@pytest.mark.filterwarnings("ignore:The __array_wrap__:DeprecationWarning")
6261
def test_dask_ufunc():
63-
# At the time of dask 2022.01.0, dask is still directly using __array_wrap__
64-
# for some ufuncs (https://github.com/dask/dask/issues/8580).
65-
6662
# dask sets "compute.use_numexpr" to False, so catch the current value
6763
# and ensure to reset it afterwards to avoid impacting other tests
6864
olduse = pd.get_option("compute.use_numexpr")

0 commit comments

Comments
 (0)