<br><br><div><span class="gmail_quote">On 1/25/07, <b class="gmail_sendername">Robert Cimrman</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Robert Cimrman wrote:<br>> Charles R Harris wrote:<br>>><br>>> In : def countmembers(a1, a2) :<br>>> ...: a = sort(a2)<br>>> ...: il = a.searchsorted(a1, side='l')<br>>> ...: ir =
a.searchsorted(a1, side='r')<br>>> ...: return ir - il<br>>> ...:<br>>> The subtraction can be replaced by != to get a boolean mask.<br>><br>> It looks good! Isn't it faster than setmember1d for unique input arrays?
<br>> I do not like setmember1d much (it is long unlike other functions in<br>> arraysetops and looks clumsy to me now and I do not understand it<br>> anymore...), so feel free to replace it.<br>><br>> BTW. setmember1d gives me the same mask as countmembers for several
<br>> non-unique inputs I tried...<br><br>But still a function like 'findsorted' returning a bool mask would be<br>handy - one searchsorted-like call could be saved in setmember1d.</blockquote><div><br>This would be easy to add. I could put in an option side='mask' that would return 1 if the object is found, 0 otherwise. The type would be integer rather than boolean but I don't see that as a big problem. If I add that, I would like to change the keyword to mode instead of side and that brings up the question of how to change the interface. It is easy to use the same meaning for both mode and side for a while, but it would be nice to issue a deprecation warning for the latter and then remove it after some fixed period of time. This is a policy question and I think the numpy team needs a policy for such things.