[Numpy-discussion] a==b for numpy arrays
Johannes Loehnert
a.u.r.e.l.i.a.n at gmx.net
Mon Dec 11 17:18:18 CST 2006
Hi,
> current behaviour. That is, what "A+B" on a blackboard in a math class
> means maps nicely to what 'a+b' means with a and b being numpy arrays. But
> 'A=B' means something completely different than 'a==b'.
This mapping is dangerous, I think A+B and A-B might be the only cases where
it actually works. A*B and A/B (=A*inv(B)) are completely different from a*b
in python.
As it is, you only have to remember that every binary operator works
element-wise.
Reasoning aside, just wrap an all(...) around your if-comparisons and you will
be fine. :-)
Johannes
More information about the Numpy-discussion
mailing list