From 132c2992574e2ebfc0678ecd0ce161fa23033f5a Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 21 Aug 2023 08:39:31 -0700 Subject: [PATCH] DEPR: BaseNoReduceTests --- pandas/tests/extension/base/__init__.py | 48 +++++++++++++++++++++---- pandas/tests/extension/base/reduce.py | 3 +- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/pandas/tests/extension/base/__init__.py b/pandas/tests/extension/base/__init__.py index 7cd55b7240d54..82b61722f5e96 100644 --- a/pandas/tests/extension/base/__init__.py +++ b/pandas/tests/extension/base/__init__.py @@ -56,12 +56,7 @@ class TestMyDtype(BaseDtypeTests): BaseUnaryOpsTests, ) from pandas.tests.extension.base.printing import BasePrintingTests -from pandas.tests.extension.base.reduce import ( # noqa: F401 - BaseBooleanReduceTests, - BaseNoReduceTests, - BaseNumericReduceTests, - BaseReduceTests, -) +from pandas.tests.extension.base.reduce import BaseReduceTests from pandas.tests.extension.base.reshaping import BaseReshapingTests from pandas.tests.extension.base.setitem import BaseSetitemTests @@ -92,3 +87,44 @@ class ExtensionTests( BaseSetitemTests, ): 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 9b56b10681e15..3dd8caaa82ae2 100644 --- a/pandas/tests/extension/base/reduce.py +++ b/pandas/tests/extension/base/reduce.py @@ -129,7 +129,8 @@ def test_reduce_frame(self, data, all_numeric_reductions, skipna): self.check_reduce_frame(ser, op_name, skipna) -# TODO: deprecate BaseNoReduceTests, BaseNumericReduceTests, BaseBooleanReduceTests +# TODO(3.0): remove BaseNoReduceTests, BaseNumericReduceTests, +# BaseBooleanReduceTests class BaseNoReduceTests(BaseReduceTests): """we don't define any reductions"""