@@ -57,7 +57,7 @@ def comp_method_OBJECT_ARRAY(op, x, y):
57
57
return result .reshape (x .shape )
58
58
59
59
60
- def masked_arith_op (x : np .ndarray , y , op ):
60
+ def _masked_arith_op (x : np .ndarray , y , op ):
61
61
"""
62
62
If the given arithmetic operation fails, attempt it again on
63
63
only the non-null elements of the input array(s).
@@ -116,7 +116,7 @@ def masked_arith_op(x: np.ndarray, y, op):
116
116
return result
117
117
118
118
119
- def na_arithmetic_op (left , right , op , is_cmp : bool = False ):
119
+ def _na_arithmetic_op (left , right , op , is_cmp : bool = False ):
120
120
"""
121
121
Return the result of evaluating op on the passed in values.
122
122
@@ -147,7 +147,7 @@ def na_arithmetic_op(left, right, op, is_cmp: bool = False):
147
147
# In this case we do not fall back to the masked op, as that
148
148
# will handle complex numbers incorrectly, see GH#32047
149
149
raise
150
- result = masked_arith_op (left , right , op )
150
+ result = _masked_arith_op (left , right , op )
151
151
152
152
if is_cmp and (is_scalar (result ) or result is NotImplemented ):
153
153
# numpy returned a scalar instead of operating element-wise
@@ -179,15 +179,15 @@ def arithmetic_op(left: ArrayLike, right: Any, op):
179
179
# on `left` and `right`.
180
180
lvalues = maybe_upcast_datetimelike_array (left )
181
181
rvalues = maybe_upcast_datetimelike_array (right )
182
- rvalues = maybe_upcast_for_op (rvalues , lvalues .shape )
182
+ rvalues = _maybe_upcast_for_op (rvalues , lvalues .shape )
183
183
184
184
if should_extension_dispatch (lvalues , rvalues ) or isinstance (rvalues , Timedelta ):
185
185
# Timedelta is included because numexpr will fail on it, see GH#31457
186
186
res_values = op (lvalues , rvalues )
187
187
188
188
else :
189
189
with np .errstate (all = "ignore" ):
190
- res_values = na_arithmetic_op (lvalues , rvalues , op )
190
+ res_values = _na_arithmetic_op (lvalues , rvalues , op )
191
191
192
192
return res_values
193
193
@@ -248,7 +248,7 @@ def comparison_op(left: ArrayLike, right: Any, op) -> ArrayLike:
248
248
# suppress warnings from numpy about element-wise comparison
249
249
warnings .simplefilter ("ignore" , DeprecationWarning )
250
250
with np .errstate (all = "ignore" ):
251
- res_values = na_arithmetic_op (lvalues , rvalues , op , is_cmp = True )
251
+ res_values = _na_arithmetic_op (lvalues , rvalues , op , is_cmp = True )
252
252
253
253
return res_values
254
254
@@ -427,7 +427,7 @@ def maybe_upcast_datetimelike_array(obj: ArrayLike) -> ArrayLike:
427
427
return obj
428
428
429
429
430
- def maybe_upcast_for_op (obj , shape : Tuple [int , ...]):
430
+ def _maybe_upcast_for_op (obj , shape : Tuple [int , ...]):
431
431
"""
432
432
Cast non-pandas objects to pandas types to unify behavior of arithmetic
433
433
and comparison operations.
0 commit comments