diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index fe4e461b0bd4f..d7bc163584969 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -634,6 +634,11 @@ class ExtensionOpsMixin(object): """ A base class for linking the operators to their dunder names """ + + @classmethod + def _create_arithmetic_method(cls, op): + raise AbstractMethodError(cls) + @classmethod def _add_arithmetic_ops(cls): cls.__add__ = cls._create_arithmetic_method(operator.add) @@ -657,6 +662,10 @@ def _add_arithmetic_ops(cls): cls.__divmod__ = cls._create_arithmetic_method(divmod) cls.__rdivmod__ = cls._create_arithmetic_method(ops.rdivmod) + @classmethod + def _create_comparison_method(cls, op): + raise AbstractMethodError(cls) + @classmethod def _add_comparison_ops(cls): cls.__eq__ = cls._create_comparison_method(operator.eq) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index f4bdb7ba86aaf..9f948e77f3d49 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -561,7 +561,6 @@ def test_td64series_add_int_series_invalid(self, tdser): with pytest.raises(TypeError): tdser + Series([2, 3, 4]) - @pytest.mark.xfail(reason='GH#19123 integer interpreted as nanoseconds') def test_td64series_radd_int_series_invalid(self, tdser): with pytest.raises(TypeError): Series([2, 3, 4]) + tdser @@ -570,7 +569,6 @@ def test_td64series_sub_int_series_invalid(self, tdser): with pytest.raises(TypeError): tdser - Series([2, 3, 4]) - @pytest.mark.xfail(reason='GH#19123 integer interpreted as nanoseconds') def test_td64series_rsub_int_series_invalid(self, tdser): with pytest.raises(TypeError): Series([2, 3, 4]) - tdser @@ -611,9 +609,7 @@ def test_td64series_add_sub_numeric_scalar_invalid(self, scalar, tdser): @pytest.mark.parametrize('vector', [ np.array([1, 2, 3]), pd.Index([1, 2, 3]), - pytest.param(Series([1, 2, 3]), - marks=pytest.mark.xfail(reason='GH#19123 integer ' - 'interpreted as nanos')) + Series([1, 2, 3]) ]) def test_td64series_add_sub_numeric_array_invalid(self, vector, dtype, tdser): @@ -777,10 +773,7 @@ def test_td64series_mul_numeric_array(self, vector, dtype, tdser): 'float64', 'float32', 'float16']) @pytest.mark.parametrize('vector', [ np.array([20, 30, 40]), - pytest.param(pd.Index([20, 30, 40]), - marks=pytest.mark.xfail(reason='__mul__ raises ' - 'instead of returning ' - 'NotImplemented')), + pd.Index([20, 30, 40]), Series([20, 30, 40]) ]) def test_td64series_rmul_numeric_array(self, vector, dtype, tdser): @@ -816,12 +809,8 @@ def test_td64series_mul_numeric_scalar(self, one, tdser): @pytest.mark.parametrize('two', [ 2, 2.0, - pytest.param(np.array(2), - marks=pytest.mark.xfail(reason='GH#19011 is_list_like ' - 'incorrectly True.')), - pytest.param(np.array(2.0), - marks=pytest.mark.xfail(reason='GH#19011 is_list_like ' - 'incorrectly True.')), + np.array(2), + np.array(2.0), ]) def test_td64series_div_numeric_scalar(self, two, tdser): # GH#4521 diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index 7d5753d03f4fc..6d712b1f85856 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -339,48 +339,3 @@ def make_signature(func): if spec.keywords: args.append('**' + spec.keywords) return args, spec.args - - -class docstring_wrapper(object): - """ - Decorator to wrap a function and provide - a dynamically evaluated doc-string. - - Parameters - ---------- - func : callable - creator : callable - return the doc-string - default : str, optional - return this doc-string on error - """ - _attrs = ['__module__', '__name__', - '__qualname__', '__annotations__'] - - def __init__(self, func, creator, default=None): - self.func = func - self.creator = creator - self.default = default - update_wrapper( - self, func, [attr for attr in self._attrs - if hasattr(func, attr)]) - - def __get__(self, instance, cls=None): - - # we are called with a class - if instance is None: - return self - - # we want to return the actual passed instance - return types.MethodType(self, instance) - - def __call__(self, *args, **kwargs): - return self.func(*args, **kwargs) - - @property - def __doc__(self): - try: - return self.creator() - except Exception as exc: - msg = self.default or str(exc) - return msg