34
34
from pandas .core .ops import roperator
35
35
36
36
37
- def fill_zeros (result , x , y ):
37
+ def _fill_zeros (result , x , y ):
38
38
"""
39
39
If this is a reversed op, then flip x,y
40
40
@@ -102,9 +102,6 @@ def mask_zero_div_zero(x, y, result: np.ndarray) -> np.ndarray:
102
102
>>> mask_zero_div_zero(x, y, result)
103
103
array([ inf, nan, -inf])
104
104
"""
105
- if not isinstance (result , np .ndarray ):
106
- # FIXME: SparseArray would raise TypeError with np.putmask
107
- return result
108
105
109
106
if is_scalar (y ):
110
107
y = np .array (y )
@@ -141,7 +138,7 @@ def mask_zero_div_zero(x, y, result: np.ndarray) -> np.ndarray:
141
138
142
139
def dispatch_fill_zeros (op , left , right , result ):
143
140
"""
144
- Call fill_zeros with the appropriate fill value depending on the operation,
141
+ Call _fill_zeros with the appropriate fill value depending on the operation,
145
142
with special logic for divmod and rdivmod.
146
143
147
144
Parameters
@@ -163,12 +160,12 @@ def dispatch_fill_zeros(op, left, right, result):
163
160
if op is divmod :
164
161
result = (
165
162
mask_zero_div_zero (left , right , result [0 ]),
166
- fill_zeros (result [1 ], left , right ),
163
+ _fill_zeros (result [1 ], left , right ),
167
164
)
168
165
elif op is roperator .rdivmod :
169
166
result = (
170
167
mask_zero_div_zero (right , left , result [0 ]),
171
- fill_zeros (result [1 ], right , left ),
168
+ _fill_zeros (result [1 ], right , left ),
172
169
)
173
170
elif op is operator .floordiv :
174
171
# Note: no need to do this for truediv; in py3 numpy behaves the way
@@ -179,7 +176,7 @@ def dispatch_fill_zeros(op, left, right, result):
179
176
# we want.
180
177
result = mask_zero_div_zero (right , left , result )
181
178
elif op is operator .mod :
182
- result = fill_zeros (result , left , right )
179
+ result = _fill_zeros (result , left , right )
183
180
elif op is roperator .rmod :
184
- result = fill_zeros (result , right , left )
181
+ result = _fill_zeros (result , right , left )
185
182
return result
0 commit comments