-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Cannot unmask structured arrays values based on predicate #22049
Copy link
Copy link
Open
Labels
component: numpy.mamasked arraysmasked arrays
Description
There seems to be an issue when trying to unmask a value in a structured array based on some predicate.
I would have expected this operation to successfully unmask the entry, but it does not - see the example below.
I'm running Ubuntu 20.04.3 and python 3.8.13
This behaviour has been observed on numpy versions 1.23.1 and 1.22.4 (the two ones i've tried).
The expected behaviour (so no AssertionError raised by the below snippet) is instead observed in 1.21.5.
out = np.ma.array(np.empty(3, dtype=[('a_string', '<U30'), ('a_float', '<f8')]), mask=True)
assert not out.hardmask
out['a_string'] = ['Aa', 'Bb', 'Cc']
pred = out['a_string'] == 'Aa'
assert pred.sum() == 1
out['a_float'][pred] = 1.23
assert not out['a_float'][pred].mask.item() # <-- fails
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
component: numpy.mamasked arraysmasked arrays