[Numpy-discussion] Truth value of an array
Matthew Brett
matthew.brett@gmail....
Fri Apr 18 08:45:56 CDT 2008
Hi,
I must say, I agree with the other posters here, that it is not
completely obvious to me that:
a = np.array([True, False])
bool(a)
should return False. Especially given:
L = [True, False]
bool(L)
returns True.
Given that it's not completely obvious, and
a.all()
is completely obvious, and readable, the current behavior seems right
to me... Otherwise someone somewhere is going to assume that bool(a)
does the same as a.any(), and run into problems. Explicit is better
than implicit...
Best,
Matthew
More information about the Numpy-discussion
mailing list