[Numpy-discussion] Truth values of arrays:

Sasha ndarray at mac.com
Fri Mar 3 10:36:01 EST 2006


On 3/3/06, Tim Hochberg <tim.hochberg at cox.net> wrote:
>  ...
> My feeling is that only shape-() arrays should be usable as truth
> values. Allowing size-1 arrays to be compared as well is just adding a
> weird, not particularly useful, corner case that's going to bite someone
> eventually.

I agree, but size-1 arrays are also special with respect to
broadcasting where they behave much like scalars:

>>> x = arange(5)
>>> x + [1]
array([1, 2, 3, 4, 5])




More information about the NumPy-Discussion mailing list