Yes Pierre,
I like this one line of elegances in Python a lot. I was thinking that the
answer lies in somewhere in masked array operations, but I proved wrong.
Thanks for your input on this small riddle.
Here is another way of doing that. (That's what I thought of initially and
what Matthias Michler responded on matplotlib mailing list.)
mask = zeros(len(a), dtype=bool)
for index in xrange(len(a)): # run through array a
if a[index] in b:
mask[index] = True
Ending with a quote about Pythonicness :)
"...that something is Pythonic when it has a sense of quality,
simplicity, clarity and elegance about it."
Gökhan
On Wed, Apr 22, 2009 at 4:49 PM, Pierre GM <[email protected]> wrote:
>
> On Apr 22, 2009, at 5:21 PM, Gökhan SEVER wrote:
>
> > Hello,
> >
> > Could you please give me some hints about how to mask an array using
> > another arrays like in the following example.
>
> What about that ?
> numpy.logical_or.reduce([a==i for i in b])
>
>
> _______________________________________________
> Numpy-discussion mailing list
> [email protected]
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion