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

DEPR: remove deprecated extension test classes #58053

Merged
merged 1 commit into from
Mar 29, 2024
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Removal of prior version deprecations/changes
- Disallow passing a pandas type to :meth:`Index.view` (:issue:`55709`)
- 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`)
- Removed the "closed" and "unit" keywords in :meth:`TimedeltaIndex.__new__` (:issue:`52628`, :issue:`55499`)
- All arguments in :meth:`Index.sort_values` are now keyword only (:issue:`56493`)
Expand Down
45 changes: 1 addition & 44 deletions pandas/tests/extension/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}'"
)
22 changes: 0 additions & 22 deletions pandas/tests/extension/base/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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