[Numpy-discussion] a==b for numpy arrays
Abel Daniel
abli at freemail.hu
Mon Dec 11 14:41:05 CST 2006
Robert Kern <robert.kern <at> gmail.com> writes:
>
> Abel Daniel wrote:
> > Now, I think that having a way of getting an element-wise comparison
> > (i.e. getting an array of bools) is great. _But_ why make that the
> > result of a '==' comparison? Is there any actual code that does, for
> > example
> >>>> result_array = a==b
> > or any variant thereof?
>
> Yes, a lot.
>
And it would be much more cumbersome to use something like
numpy.eq_as_array(a,b) or a.eq_as_array(b) in these cases?
Could you show an example so that I can better appreciate the difference?
The thing I can't get into my head is that '=' in the mathematical sense has a
well-defined meaning for matrices, this seems to be broken by the 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'.
I tried to dig up something about this "'a==b' return an array" decision from
the discussion surrounding PEP 207 (on comp.lang.python or on python-dev) but I
got lost in that thread.
--
Daniel
More information about the Numpy-discussion
mailing list