Re: [Numpy-discussion] finding elements that match any in a set

2011-05-29 Thread eat
On Sun, May 29, 2011 at 10:58 PM, Chris Barker wrote: > > On 5/28/2011 3:40 PM, Robert wrote: > >> (myarray in mylist) turns into mylist.__contains__(myarray). > >> Only the list object is ever checked for this method. There is no > >> paired method myarray.__rcontains__(mylist) so there is nothin

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-29 Thread Michael Katz
l the available numpy function names. ________ From: Neil Crighton To: numpy-discussion@scipy.org Sent: Sun, May 29, 2011 10:03:25 AM Subject: Re: [Numpy-discussion] finding elements that match any in a set Michael Katz yahoo.com> writes: > Yes, thanks, np.in1d is w

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-29 Thread Chris Barker
> On 5/28/2011 3:40 PM, Robert wrote: >> (myarray in mylist) turns into mylist.__contains__(myarray). >> Only the list object is ever checked for this method. There is no >> paired method myarray.__rcontains__(mylist) so there is nothing that >> numpy can override to make this operation do anything

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-29 Thread Neil Crighton
Michael Katz yahoo.com> writes: > Yes, thanks, np.in1d is what I needed. I didn't know how to find that. Did you check in the documentation? If so, where did you check? Would you have found it if it was in the 'See also' section of where()? (http://docs.scipy.org/doc/numpy/reference/generated/n

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-29 Thread Alan G Isaac
On 5/28/2011 3:46 PM, Robert Kern wrote: > mylist.__contains__(x), it should treat all objects exactly > the same: check if it equals any item that it contains. There is no > way for it to say, "Oh, I don't know how to deal with this type, so > I'll pass it over to x.__contains__()". Which makes

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-29 Thread Alan G Isaac
On 5/28/2011 3:40 PM, Robert wrote: > (myarray in mylist) turns into mylist.__contains__(myarray). > Only the list object is ever checked for this method. There is no > paired method myarray.__rcontains__(mylist) so there is nothing that > numpy can override to make this operation do anything diffe

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-28 Thread Robert Kern
On Sat, May 28, 2011 at 14:40, Michael Katz wrote: > Thanks for the explanation. It sounds like Python needs __rcontains__. Not really. For the mathematical operators, there are good ways for the operands to "know" what types they can deal with and which they can't. For mylist.__contains__(x), it

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-28 Thread Michael Katz
Thanks for the explanation. It sounds like Python needs __rcontains__. From: Robert Kern To: Discussion of Numerical Python Sent: Sat, May 28, 2011 12:30:05 PM Subject: Re: [Numpy-discussion] finding elements that match any in a set On Sat, May 28, 2011 at 14

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-28 Thread Robert Kern
On Sat, May 28, 2011 at 14:18, Michael Katz wrote: > Yes, thanks, np.in1d is what I needed. I didn't know how to find that. > > It still seems counterintuitive to me that > >     indexes = np.where( records.integer_field in values ) > > does not work whereas > >     indexes = np.where( records.int

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-28 Thread Michael Katz
d get overridden the same way. From: Christopher Barker To: Discussion of Numerical Python Sent: Fri, May 27, 2011 5:48:37 PM Subject: Re: [Numpy-discussion] finding elements that match any in a set On 5/27/11 9:48 AM, Michael Katz wrote: > I have a numpy array, rec

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-27 Thread Christopher Barker
On 5/27/11 9:48 AM, Michael Katz wrote: > I have a numpy array, records, with named fields including a field named > "integer_field". I have an array (or list) of values of interest, and I > want to get the indexes where integer_field has any of those values. > > Because I can do > > indexes = np.w

Re: [Numpy-discussion] finding elements that match any in a set

2011-05-27 Thread Skipper Seabold
On Fri, May 27, 2011 at 12:48 PM, Michael Katz wrote: > I have a numpy array, records, with named fields including a field named > "integer_field". I have an array (or list) of values of interest, and I want > to get the indexes where integer_field has any of those values. > > Because I can do > >

[Numpy-discussion] finding elements that match any in a set

2011-05-27 Thread Michael Katz
I have a numpy array, records, with named fields including a field named "integer_field". I have an array (or list) of values of interest, and I want to get the indexes where integer_field has any of those values. Because I can do indexes = np.where( records.integer_field > 5 ) I thought I