From db80cabc99343b8d6759bb35b32f55018702419a Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 29 Mar 2024 11:23:43 -0700 Subject: [PATCH] DEPR: remove deprecated extension test classes (#58053) --- doc/source/whatsnew/v3.0.0.rst | 1 + pandas/tests/extension/base/__init__.py | 45 +------------------------ pandas/tests/extension/base/reduce.py | 22 ------------ 3 files changed, 2 insertions(+), 66 deletions(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index bc9c48fb60d22..d6060d4fa241f 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -212,6 +212,7 @@ Removal of prior version deprecations/changes - Disallow units other than "s", "ms", "us", "ns" for datetime64 and timedelta64 dtypes in :func:`array` (:issue:`53817`) - Removed "freq" keyword from :class:`PeriodArray` constructor, use "dtype" instead (:issue:`52462`) - Removed deprecated "method" and "limit" keywords from :meth:`Series.replace` and :meth:`DataFrame.replace` (:issue:`53492`) +- Removed extension test classes ``BaseNoReduceTests``, ``BaseNumericReduceTests``, ``BaseBooleanReduceTests`` (:issue:`54663`) - Removed the "closed" and "normalize" keywords in :meth:`DatetimeIndex.__new__` (:issue:`52628`) - Stopped performing dtype inference with in :meth:`Index.insert` with object-dtype index; this often affects the index/columns that result when setting new entries into an empty :class:`Series` or :class:`DataFrame` (:issue:`51363`) - Removed the "closed" and "unit" keywords in :meth:`TimedeltaIndex.__new__` (:issue:`52628`, :issue:`55499`) diff --git a/pandas/tests/extension/base/__init__.py b/pandas/tests/extension/base/__init__.py index cfbc365568403..2abf739d2428d 100644 --- a/pandas/tests/extension/base/__init__.py +++ b/pandas/tests/extension/base/__init__.py @@ -64,9 +64,7 @@ class TestMyDtype(BaseDtypeTests): # One test class that you can inherit as an alternative to inheriting all the # test classes above. -# Note 1) this excludes Dim2CompatTests and NDArrayBacked2DTests. -# Note 2) this uses BaseReduceTests and and _not_ BaseBooleanReduceTests, -# BaseNoReduceTests, or BaseNumericReduceTests +# Note this excludes Dim2CompatTests and NDArrayBacked2DTests. class ExtensionTests( BaseAccumulateTests, BaseCastingTests, @@ -89,44 +87,3 @@ class ExtensionTests( Dim2CompatTests, ): pass - - -def __getattr__(name: str): - import warnings - - if name == "BaseNoReduceTests": - warnings.warn( - "BaseNoReduceTests is deprecated and will be removed in a " - "future version. Use BaseReduceTests and override " - "`_supports_reduction` instead.", - FutureWarning, - ) - from pandas.tests.extension.base.reduce import BaseNoReduceTests - - return BaseNoReduceTests - - elif name == "BaseNumericReduceTests": - warnings.warn( - "BaseNumericReduceTests is deprecated and will be removed in a " - "future version. Use BaseReduceTests and override " - "`_supports_reduction` instead.", - FutureWarning, - ) - from pandas.tests.extension.base.reduce import BaseNumericReduceTests - - return BaseNumericReduceTests - - elif name == "BaseBooleanReduceTests": - warnings.warn( - "BaseBooleanReduceTests is deprecated and will be removed in a " - "future version. Use BaseReduceTests and override " - "`_supports_reduction` instead.", - FutureWarning, - ) - from pandas.tests.extension.base.reduce import BaseBooleanReduceTests - - return BaseBooleanReduceTests - - raise AttributeError( - f"module 'pandas.tests.extension.base' has no attribute '{name}'" - ) diff --git a/pandas/tests/extension/base/reduce.py b/pandas/tests/extension/base/reduce.py index 6ea1b3a6fbe9d..03952d87f0ac6 100644 --- a/pandas/tests/extension/base/reduce.py +++ b/pandas/tests/extension/base/reduce.py @@ -129,25 +129,3 @@ def test_reduce_frame(self, data, all_numeric_reductions, skipna): pytest.skip(f"Reduction {op_name} not supported for this dtype") self.check_reduce_frame(ser, op_name, skipna) - - -# TODO(3.0): remove BaseNoReduceTests, BaseNumericReduceTests, -# BaseBooleanReduceTests -class BaseNoReduceTests(BaseReduceTests): - """we don't define any reductions""" - - -class BaseNumericReduceTests(BaseReduceTests): - # For backward compatibility only, this only runs the numeric reductions - def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool: - if op_name in ["any", "all"]: - pytest.skip("These are tested in BaseBooleanReduceTests") - return True - - -class BaseBooleanReduceTests(BaseReduceTests): - # For backward compatibility only, this only runs the numeric reductions - def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool: - if op_name not in ["any", "all"]: - pytest.skip("These are tested in BaseNumericReduceTests") - return True