I want to modify an existing mask for further use in my code according to some condition:
import pylab
mask1 = arange(10) > 5;
# [False False False False False False True True True True]
mask2 = arange(10) >8;
# [False False False False False False False False False True]
mask1[mask2] = False
print mask1
[ True False False False False False True True True True]
As you see it was the first element the one that was modified and not the last one as expected. What is the right way to do this?
EDIT: Sorry my bad, as some of you pointed out the code is correct, I don’t know what was going on there, I will just delete the question.
There’s nothing wrong with your code. I have tried it, and it produces the correct result (which is different to the result you show).
Here is an alternative way to do the same thing: