Robert Cimrman wrote:
> Charles R Harris wrote:
>>
>> In [7]: def countmembers(a1, a2) :
>>   ...:     a = sort(a2)
>>   ...:     il = a.searchsorted(a1, side='l')
>>   ...:     ir = a.searchsorted(a1, side='r')
>>   ...:     return ir - il
>>   ...:
>> The subtraction can be replaced by != to get a boolean mask.
> 
> It looks good! Isn't it faster than setmember1d for unique input arrays?
> I do not like setmember1d much (it is long unlike other functions in
> arraysetops and looks clumsy to me now and I do not understand it
> anymore...), so feel free to replace it.
> 
> BTW. setmember1d gives me the same mask as countmembers for several
> non-unique inputs I tried...

But still a function like 'findsorted' returning a bool mask would be
handy - one searchsorted-like call could be saved in setmember1d.

cheers,
r.
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to