Re: [Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-13 Thread Robert Kern
On Sun, Sep 13, 2009 at 05:30, Robert wrote: > Neil Martinsen-Burrell wrote: >> On 2009-09-07 07:11 , Robert wrote: >>> Is there a reason why ndarray truth tests (except scalars) >>> deviates from the convention of other Python iterables >>> list,array.array,str,dict,... ? >>> >>> Furthermore ther

Re: [Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-13 Thread josef . pktd
On Sun, Sep 13, 2009 at 9:05 AM, Alan G Isaac wrote: > On 9/13/2009 7:46 AM, Robert wrote: >> 2 ways seem to be consistently Pythonic and logical: "size> >> 0"; or "any(a)" (*); and the later option may be more 'numerical'. > > Well, *there's* the problem. > > As a user I have felt more than once

Re: [Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-13 Thread Alan G Isaac
On 9/13/2009 7:46 AM, Robert wrote: > 2 ways seem to be consistently Pythonic and logical: "size> > 0"; or "any(a)" (*); and the later option may be more 'numerical'. Well, *there's* the problem. As a user I have felt more than once that a length based test, like other containers, would be natura

Re: [Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-13 Thread Robert
Robert wrote: > Neil Martinsen-Burrell wrote: >> On 2009-09-07 07:11 , Robert wrote: >>> Is there a reason why ndarray truth tests (except scalars) >>> deviates from the convention of other Python iterables >>> list,array.array,str,dict,... ? >>> >>> Furthermore there is a surprising strange except

Re: [Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-13 Thread Robert
Neil Martinsen-Burrell wrote: > On 2009-09-07 07:11 , Robert wrote: >> Is there a reason why ndarray truth tests (except scalars) >> deviates from the convention of other Python iterables >> list,array.array,str,dict,... ? >> >> Furthermore there is a surprising strange exception for arrays >> with

Re: [Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-07 Thread Neil Martinsen-Burrell
On 2009-09-07 07:11 , Robert wrote: > Is there a reason why ndarray truth tests (except scalars) > deviates from the convention of other Python iterables > list,array.array,str,dict,... ? > > Furthermore there is a surprising strange exception for arrays > with size 1 (!= scalars). Historically, n

[Numpy-discussion] Why is the truth value of ndarray not simply size>0 ?

2009-09-07 Thread Robert
Is there a reason why ndarray truth tests (except scalars) deviates from the convention of other Python iterables list,array.array,str,dict,... ? Furthermore there is a surprising strange exception for arrays with size 1 (!= scalars). I often run into exceptions and unexpected bahavior like sh