<div dir="ltr"><div><div><div><div>Thank-you for your explanations.<br><br></div>So, if  the operator  "==" applied to np.arrays is a shorthand for the ufunc np.equal, it should definitly behave exactly as np.equal(), and raise an error.<br>
<br></div>One side question about style : In case you would like to protect a "x == y" test by a try/except clause, wouldn't it feel more "natural" to write " np.equal(x, y)" ?<br><br><br>
</div><div>Bruno.<br></div><div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/15 Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, Jul 15, 2013 at 2:09 PM, bruno Piguet <<a href="mailto:bruno.piguet@gmail.com">bruno.piguet@gmail.com</a>> wrote:<br>

> Python itself doesn't raise an exception in such cases :<br>
><br>
>>>> (3,4) != (2, 3, 4)<br>
> True<br>
>>>> (3,4) == (2, 3, 4)<br>
> False<br>
><br>
> Should numpy behave differently ?<br>
<br>
</div>The numpy equivalent to Python's scalar "==" is called array_equal,<br>
and that does indeed behave the same:<br>
<br>
In [5]: np.array_equal([3, 4], [2, 3, 4])<br>
Out[5]: False<br>
<br>
But in numpy, the name "==" is shorthand for the ufunc np.equal, which<br>
raises an error:<br>
<br>
In [8]: np.equal([3, 4], [2, 3, 4])<br>
ValueError: operands could not be broadcast together with shapes (2) (3)<br>
<span class="HOEnZb"><font color="#888888"><br>
-n<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div>