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
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
___
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
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([],
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
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([],
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
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
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