Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Nadav Horesh
Subject: [Numpy-discussion] Is this odd? Hi All, Below is some array behaviour which i think is odd a=arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b=nonzero(a0) b (array([], dtype=int32),) if not b[0]: ... print 'b[0] is false' ... b[0] is false Above case the b[0] is empty so

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Alan G Isaac
On 4/2/2010 8:29 AM, Nadav Horesh wrote: In python empty sequences are always equivalent to False, and non-empty to True. I think that was why the OP objected to this behavior: bool(np.array([0])) False Alan Isaac ___

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Robert Kern
On Thu, Apr 1, 2010 at 22:07, Shailendra shailendra.vi...@gmail.com wrote: Hi All, Below is some array behaviour which i think is odd a=arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b=nonzero(a0) b (array([], dtype=int32),) if not b[0]: ...     print 'b[0] is false' ... b[0] is

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread josef . pktd
On Fri, Apr 2, 2010 at 10:11 AM, Robert Kern robert.k...@gmail.com wrote: On Thu, Apr 1, 2010 at 22:07, Shailendra shailendra.vi...@gmail.com wrote: Hi All, Below is some array behaviour which i think is odd a=arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b=nonzero(a0) b (array([],

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Ryan May
On Thu, Apr 1, 2010 at 10:07 PM, Shailendra shailendra.vi...@gmail.com wrote: Hi All, Below is some array behaviour which i think is odd a=arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b=nonzero(a0) b (array([], dtype=int32),) if not b[0]: ...     print 'b[0] is false' ... b[0] is

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Robert Kern
On Fri, Apr 2, 2010 at 08:28, Ryan May rma...@gmail.com wrote: On Thu, Apr 1, 2010 at 10:07 PM, Shailendra shailendra.vi...@gmail.com wrote: Hi All, Below is some array behaviour which i think is odd a=arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b=nonzero(a0) b (array([],

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Shailendra
Thanks everyone for replies/suggestion. It is simple to avoid this problem. But my point that given the behavior of python this behavior seems inconsistent. There could other method provided which could evaluate bool value depending on values stored in the array. Thanks, Shailendra On Fri, Apr

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Ryan May
On Fri, Apr 2, 2010 at 8:31 AM, Robert Kern robert.k...@gmail.com wrote: On Fri, Apr 2, 2010 at 08:28, Ryan May rma...@gmail.com wrote: On Thu, Apr 1, 2010 at 10:07 PM, Shailendra shailendra.vi...@gmail.com wrote: Hi All, Below is some array behaviour which i think is odd a=arange(10) a

[Numpy-discussion] Is this odd?

2010-04-01 Thread Shailendra
Hi All, Below is some array behaviour which i think is odd a=arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b=nonzero(a0) b (array([], dtype=int32),) if not b[0]: ... print 'b[0] is false' ... b[0] is false Above case the b[0] is empty so it is fine it is considered false