[Numpy-discussion] setmember1d memory leak?

Charles R Harris charlesr.harris at gmail.com
Fri Jan 26 11:36:02 CST 2007


On 1/25/07, Robert Cimrman <cimrman3 at ntc.zcu.cz> wrote:
>
> 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.


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.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070126/4e93a17d/attachment.html 


More information about the Numpy-discussion mailing list