Skip to content

Commit

Permalink
DEPR: remove deprecated extension test classes (pandas-dev#58053)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and pmhatre1 committed May 7, 2024
1 parent 8f1b45a commit db80cab
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 66 deletions.
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 @@ -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`)
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

0 comments on commit db80cab

Please # to comment.