You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But masked_where didn't quite do this, and was recently changed in 1.21 to match what the docs actually say in #18967. While it seems to have propagated to e.g., masked_less, it has not affected masked_invalid, which continues to not modify a.
Note though, that unlike masked_where, a partially masked input array does not 'fix' copy=False to match the docs, as in #18946. So changing this behaviour might be more problematic and it might be better to make this explicit in the docs instead.
Reproducing code example:
masked_where modifies input:
In [1]: importnumpyasnpIn [25]: a=np.ma.array([np.inf, 1, 2, 3, 4])
In [26]: aOut[26]:
masked_array(data=[inf, 1., 2., 3., 4.],
mask=False,
fill_value=1e+20)
In [28]: np.ma.masked_where(a==3, a, copy=False)
Out[28]:
masked_array(data=[inf, 1.0, 2.0, --, 4.0],
mask=[False, False, False, True, False],
fill_value=1e+20)
In [29]: aOut[29]:
masked_array(data=[inf, 1.0, 2.0, --, 4.0],
mask=[False, False, False, True, False],
fill_value=1e+20)
Hello everybody,
I see this issue is labeled for sprints, may I have a look at it even outside a sprint?
If so, may I ask which solution is recommended by numpy developers?
So changing this behaviour might be more problematic and it might be better to make this explicit in the docs instead.
It would be better to clarify the documentation or make mask_invalid consistent with masked_where?
Thanks!
Uh oh!
There was an error while loading. Please reload this page.
According to
masked_invalid
docs, it is a shortcut formasked_where
, which says thatcopy=False
will modifya
in place.But
masked_where
didn't quite do this, and was recently changed in 1.21 to match what the docs actually say in #18967. While it seems to have propagated to e.g.,masked_less
, it has not affectedmasked_invalid
, which continues to not modifya
.Note though, that unlike
masked_where
, a partially masked input array does not 'fix'copy=False
to match the docs, as in #18946. So changing this behaviour might be more problematic and it might be better to make this explicit in the docs instead.Reproducing code example:
masked_where
modifies input:Other wrappers like
masked_equal
modify input:But
masked_invalid
does not:And unlike
masked_where
before, it does not magically work again for a partially masked array:NumPy/Python version information:
The text was updated successfully, but these errors were encountered: