Skip to content

Commit 7489224

Browse files
authored
REF: define arithmetic methods non-dynamically (#51813)
* REF: move alignment functions to DataFrame/Series methods * REF: define flex arithmetic/comparison methods non-dynamically * REF: Consolidate Frame/Series arithmetic helpers in ops.methods * REF: move Series arithmetic helpers * move fill_binop * pyright ignore * fix ops.__init__.__all__ * annotate * REF: move everything back to Series/DataFrame classes * fix doctest
1 parent 23e2841 commit 7489224

File tree

13 files changed

+738
-680
lines changed

13 files changed

+738
-680
lines changed

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ def __array__(self, dtype: NpDtype | None = None) -> np.ndarray:
13491349

13501350
def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
13511351
# for binary ops, use our custom dunder methods
1352-
result = ops.maybe_dispatch_ufunc_to_dunder_op(
1352+
result = arraylike.maybe_dispatch_ufunc_to_dunder_op(
13531353
self, ufunc, method, *inputs, **kwargs
13541354
)
13551355
if result is not NotImplemented:

pandas/core/arrays/masked.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
525525
return NotImplemented
526526

527527
# for binary ops, use our custom dunder methods
528-
result = ops.maybe_dispatch_ufunc_to_dunder_op(
528+
result = arraylike.maybe_dispatch_ufunc_to_dunder_op(
529529
self, ufunc, method, *inputs, **kwargs
530530
)
531531
if result is not NotImplemented:

pandas/core/arrays/numpy_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
142142
# in PandasArray, since pandas' ExtensionArrays are 1-d.
143143
out = kwargs.get("out", ())
144144

145-
result = ops.maybe_dispatch_ufunc_to_dunder_op(
145+
result = arraylike.maybe_dispatch_ufunc_to_dunder_op(
146146
self, ufunc, method, *inputs, **kwargs
147147
)
148148
if result is not NotImplemented:

pandas/core/arrays/sparse/array.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@
7878
notna,
7979
)
8080

81-
from pandas.core import (
82-
arraylike,
83-
ops,
84-
)
81+
from pandas.core import arraylike
8582
import pandas.core.algorithms as algos
8683
from pandas.core.arraylike import OpsMixin
8784
from pandas.core.arrays import ExtensionArray
@@ -1643,7 +1640,7 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
16431640
return NotImplemented
16441641

16451642
# for binary ops, use our custom dunder methods
1646-
result = ops.maybe_dispatch_ufunc_to_dunder_op(
1643+
result = arraylike.maybe_dispatch_ufunc_to_dunder_op(
16471644
self, ufunc, method, *inputs, **kwargs
16481645
)
16491646
if result is not NotImplemented:

pandas/core/computation/expressions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
from pandas.util._exceptions import find_stack_level
1919

20+
from pandas.core import roperator
2021
from pandas.core.computation.check import NUMEXPR_INSTALLED
21-
from pandas.core.ops import roperator
2222

2323
if NUMEXPR_INSTALLED:
2424
import numexpr as ne

0 commit comments

Comments
 (0)