numpy
numpy copied to clipboard
BUG: `np.ma.allequal` fails when comparing masked array with itself
Describe the issue:
np.ma.allequal(a, a, fill_value=False) should return True if a is a masked array with the mask being all False
It works if the mask is nomask but not if it is [False, False, ...]
The bug only occurs if the masks of the two arrays are object equal (see example)
Reproduce the code example:
import numpy as np
a = np.ma.masked_array([1,2,3], mask=[0,0,0])
b = np.ma.masked_array([1,2,3], mask=[0,0,0])
assert np.ma.allequal(a, b, fill_value=False) # this works
assert np.ma.allequal(a, a, fill_value=False) # this fails
Error message:
No response
Python and NumPy Versions:
numpy: 2.0.0 python: 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:13:44) [Clang 16.0.6 ]
Runtime Environment:
No response
Context for the issue:
No response