[Numpy-discussion] Truth value of an array
Matthew Brett
matthew.brett at gmail.com
Fri Apr 18 09:45:56 EDT 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