BUG: fix ma.minimum.reduce with axis keyword#21993
Conversation
Adapted from the problem reported at numpy#21977 (comment)
Fixes the problem reported at numpy#21977 (comment) The reduce method here effectively calls itself with an unmasked MaskedArray (mask=nomask) and then expects either a MaskedArray or a scalar. This change ensures that an ordinary ndarray is converted to a MaskedArray, following the pattern already used in mean and var in this module.
|
Thanks @rcomer |
|
Hi-five on merging your first pull request to NumPy, @rcomer! We hope you stick around! Your choices aren’t limited to programming – you can review pull requests, help us stay on top of new and old issues, develop educational material, work on our website, add or improve graphic design, create marketing materials, translate website content, write grant proposals, and help with other fundraising initiatives. For more info, check out: https://numpy.org/contribute |
Fixes the problem reported at #21977 (comment).
The
reducemethod here effectively calls itself with an unmaskedMaskedArray(mask=nomask) and then expects either aMaskedArrayor a scalar. This change ensures that an ordinaryndarrayis converted to aMaskedArray, following the pattern already used inmeanandvarin this module.When
twas anndarray, we calledelif mon a boolean array, triggering the "ambiguous truth value" error.numpy/numpy/ma/core.py
Lines 6883 to 6886 in bdec321