On Thu, Jun 4, 2009 at 8:23 AM, Alan G Isaac <ais...@american.edu> wrote:
> a[(a==b[:,None]).sum(axis=0,dtype=bool)]

this is my preferred way when b is small and has unique elements.
if the elements in b are not unique, then be can be replaced by np.unique(b)
If b is large this creates a huge intermediate array

The advantage of the new setmember1d_nu is that it handles large b
very efficiently. My try on it was more than 10 times slower than the
proposed solution for larger arrays.

Josef

> hth,
> Alan Isaac
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to