Re: [Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-26 Thread Nathaniel Smith
On Tue, Feb 26, 2013 at 10:21 AM, Sebastian Berg wrote: > On Mon, 2013-02-25 at 16:33 +, Nathaniel Smith wrote: >> On Mon, Feb 25, 2013 at 3:10 PM, Sebastian Berg >> wrote: >> > Hello all, >> > >> > currently the `__contains__` method or the `in` operator on arrays, does >> > not return what

Re: [Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-26 Thread Sebastian Berg
On Mon, 2013-02-25 at 16:33 +, Nathaniel Smith wrote: > On Mon, Feb 25, 2013 at 3:10 PM, Sebastian Berg > wrote: > > Hello all, > > > > currently the `__contains__` method or the `in` operator on arrays, does > > not return what the user would expect when in the operation `a in b` the > > `a`

Re: [Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-25 Thread Sebastian Berg
On Mon, 2013-02-25 at 18:01 +0100, Todd wrote: > The problem with b is that it breaks down if the two status have the > same dimensionality. > > I think a better approach would be for > > a in b > > With a having n dimensions, it returns true if there is any subarray > of b that matches a alon

Re: [Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-25 Thread Sebastian Berg
On Mon, 2013-02-25 at 16:33 +, Nathaniel Smith wrote: > On Mon, Feb 25, 2013 at 3:10 PM, Sebastian Berg > wrote: > > Hello all, > > > > currently the `__contains__` method or the `in` operator on arrays, does > > not return what the user would expect when in the operation `a in b` the > > `a`

Re: [Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-25 Thread Todd
The problem with b is that it breaks down if the two status have the same dimensionality. I think a better approach would be for a in b With a having n dimensions, it returns true if there is any subarray of b that matches a along the last n dimensions. So if a has 3 dimensions and b has 6, a i

Re: [Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-25 Thread Nathaniel Smith
On Mon, Feb 25, 2013 at 3:10 PM, Sebastian Berg wrote: > Hello all, > > currently the `__contains__` method or the `in` operator on arrays, does > not return what the user would expect when in the operation `a in b` the > `a` is not a single element (see "In [3]-[4]" below). True, I did not expec

[Numpy-discussion] What should np.ndarray.__contains__ do

2013-02-25 Thread Sebastian Berg
Hello all, currently the `__contains__` method or the `in` operator on arrays, does not return what the user would expect when in the operation `a in b` the `a` is not a single element (see "In [3]-[4]" below). The first solution coming to mind might be checking `all()` for all dimensions given i