@@ -47,7 +47,7 @@ def _fill_zeros(result, x, y):
47
47
if is_float_dtype (result .dtype ):
48
48
return result
49
49
50
- is_variable_type = hasattr (y , "dtype" ) or hasattr ( y , "type" )
50
+ is_variable_type = hasattr (y , "dtype" )
51
51
is_scalar_type = is_scalar (y )
52
52
53
53
if not is_variable_type and not is_scalar_type :
@@ -58,19 +58,18 @@ def _fill_zeros(result, x, y):
58
58
59
59
if is_integer_dtype (y .dtype ):
60
60
61
- if (y == 0 ).any ():
61
+ ymask = y == 0
62
+ if ymask .any ():
62
63
63
- # GH#7325, mask and nans must be broadcastable (also: GH#9308)
64
- # Raveling and then reshaping makes np.putmask faster
65
- mask = ((y == 0 ) & ~ np .isnan (result )).ravel ()
64
+ # GH#7325, mask and nans must be broadcastable
65
+ mask = ymask & ~ np .isnan (result )
66
66
67
- shape = result .shape
68
- result = result .astype ("float64" , copy = False ).ravel ()
67
+ # GH#9308 doing ravel on result and mask can improve putmask perf,
68
+ # but can also make unwanted copies.
69
+ result = result .astype ("float64" , copy = False )
69
70
70
71
np .putmask (result , mask , np .nan )
71
72
72
- result = result .reshape (shape )
73
-
74
73
return result
75
74
76
75
0 commit comments