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
The function np.ma.min works correctly with MaskedArrays, ndarrays and lists of the earlier arrays. np.ma.min handles lists of arrays by converting them to MaskedArrays. np.min is an alias for np.amin that tries to call obj.min. If the object does not have a min method, it appears to be first converted to an ndarray and then it's min method can be called. I couldn't find the specific code for this last claim, but you can execute np.array([ma]).min() to get the same outcome as calling np.min([ma]).
In short: the difference between np.min and np.ma.min is that they convert objects without a min method (e.g. lists) to different kinds of arrays.
Describe the issue:
I'm almost sure this is intended, but it caught me by surprise.
We have that
min(a.min(), b.min()) != np.min([a, b])
when(a, b)
are masked arrays, but I expected them to be the same.This also applies to other functions, such as
np.max
,np.nanmin
,np.nanmax
, and probably other reduce functions.Reproduce the code example:
Error message:
No response
NumPy/Python version information:
1.21.4 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: