|
1 | | -import operator |
2 | 1 | from typing import TYPE_CHECKING, Type, Union |
3 | 2 |
|
4 | 3 | import numpy as np |
|
15 | 14 | pandas_dtype, |
16 | 15 | ) |
17 | 16 |
|
18 | | -from pandas import compat |
19 | 17 | from pandas.core import ops |
20 | 18 | from pandas.core.arrays import IntegerArray, PandasArray |
21 | 19 | from pandas.core.arrays.integer import _IntegerDtype |
@@ -344,26 +342,7 @@ def _cmp_method(self, other, op): |
344 | 342 | result[valid] = op(self._ndarray[valid], other) |
345 | 343 | return BooleanArray(result, mask) |
346 | 344 |
|
347 | | - # Override parent because we have different return types. |
348 | | - @classmethod |
349 | | - def _create_arithmetic_method(cls, op): |
350 | | - # Note: this handles both arithmetic and comparison methods. |
351 | | - |
352 | | - assert op.__name__ in ops.ARITHMETIC_BINOPS | ops.COMPARISON_BINOPS |
353 | | - |
354 | | - @ops.unpack_zerodim_and_defer(op.__name__) |
355 | | - def method(self, other): |
356 | | - return self._cmp_method(other, op) |
357 | | - |
358 | | - return compat.set_function_name(method, f"__{op.__name__}__", cls) |
359 | | - |
360 | | - @classmethod |
361 | | - def _add_arithmetic_ops(cls): |
362 | | - cls.__add__ = cls._create_arithmetic_method(operator.add) |
363 | | - cls.__radd__ = cls._create_arithmetic_method(ops.radd) |
364 | | - |
365 | | - cls.__mul__ = cls._create_arithmetic_method(operator.mul) |
366 | | - cls.__rmul__ = cls._create_arithmetic_method(ops.rmul) |
| 345 | + _arith_method = _cmp_method |
367 | 346 |
|
368 | 347 | # ------------------------------------------------------------------------ |
369 | 348 | # String methods interface |
@@ -417,6 +396,3 @@ def _str_map(self, f, na_value=None, dtype=None): |
417 | 396 | # or .findall returns a list). |
418 | 397 | # -> We don't know the result type. E.g. `.get` can return anything. |
419 | 398 | return lib.map_infer_mask(arr, f, mask.view("uint8")) |
420 | | - |
421 | | - |
422 | | -StringArray._add_arithmetic_ops() |
0 commit comments