[Numpy-discussion] Truth value of an array
Fri Apr 18 06:11:37 CDT 2008
In mathematics, if I compare two function, it means that I compare on
all its "coordinates". If I say "f < g" I mean "f(x) < g(x) for all
The same holds for a vector, if I write "v == w" I mean "v[i] == w[i]
for all i".
How come this doesn't work in numpy? And why the message about the
truth value of an array being ambiguous? What is ambiguous?
In my opinion any boolean array should be cast with all()
automatically so that people can simply write:
if v == w:
Or is there a good reason why this is not possible?
More information about the Numpy-discussion