Comparing rows in a structured masked array raises exception
from numpy import ma marr = ma.array([(1,2), (3,4)], dtype=[('x', int), ('y', int)]) marr.mask[0][0] = True marr.mask[1][0] = True marr[0] == marr[1] Traceback (most recent call last): File "<ipython-input-5-fecaee6f2991>", line 1, in <module> marr[0] == marr[1] File "/data/cosmos2/ska/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/numpy/ma/core.py",
When comparing rows of a structured masked array I'm getting an exception. A similar operation on an structured ndarray gives the expected True/False result. Note that this exception only occurs if one or more of the mask values are True, since otherwise both row objects are np.void and the ndarray behavior is obtained. (See PR #483, which seems like a good idea to me, compatibility issues notwithstanding). line 3573, in __eq__ check = ndarray.__eq__(self.filled(0), odata).view(type(self)) TypeError: descriptor '__eq__' requires a 'numpy.ndarray' object but received a 'numpy.void'
arr = np.array([(1,2), (3,4)], dtype=[('x', int), ('y', int)]) arr[0] == arr[1] False
np.__version__ '1.6.2'
Thanks, Tom
participants (1)
-
Tom Aldcroft