allclose changed behaviour in 1.6.2 ?
Hi, We noticed that comparing arrays of different shapes with allclose doesn't work anymore in numpy 1.6.2. Is this a feature or a bug ? :) See the output in both 1.6.1 and 1.6.2 at the end of this mail. Best regards, Martin 1.6.1:: In [1]: import numpy as np In [2]: np.__version__ Out[2]: '1.6.1' In [3]: a = np.array([1, 2, 3]) In [4]: b = np.array([1, 2, 3, 4]) In [5]: np.allclose(a, b) Out[5]: False 1.6.2:: In[1]: import numpy as np In[2]: np.__version__ Out[2]: '1.6.2' In [3]: a = np.array([1, 2, 3]) In[4]: b = np.array([1, 2, 3, 4]) In[5]: np.allclose(a, b) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/maarten/pytroll/local/lib/python2.7/site-packages/numpy-1.6.2-py2.7-linux-x86_64.egg/numpy/core/numeric.py", line 1936, in allclose return all(less_equal(abs(x-y), atol + rtol * abs(y))) ValueError: operands could not be broadcast together with shapes (3) (4)
On Fri, Nov 30, 2012 at 9:07 AM, Martin Raspaud <martin.raspaud@smhi.se>wrote:
Hi,
We noticed that comparing arrays of different shapes with allclose doesn't work anymore in numpy 1.6.2.
Is this a feature or a bug ? :)
I vote for feature. Allclose does element-wise comparison, so using different size non-broadcastable inputs is an error in user code. It should have raised ValueError in 1.6.1 also. Ralf
See the output in both 1.6.1 and 1.6.2 at the end of this mail.
Best regards, Martin
1.6.1::
In [1]: import numpy as np
In [2]: np.__version__ Out[2]: '1.6.1'
In [3]: a = np.array([1, 2, 3])
In [4]: b = np.array([1, 2, 3, 4])
In [5]: np.allclose(a, b) Out[5]: False
1.6.2::
In[1]: import numpy as np
In[2]: np.__version__ Out[2]: '1.6.2'
In [3]: a = np.array([1, 2, 3])
In[4]: b = np.array([1, 2, 3, 4])
In[5]: np.allclose(a, b) Traceback (most recent call last): File "<stdin>", line 1, in <module> File
"/home/maarten/pytroll/local/lib/python2.7/site-packages/numpy-1.6.2-py2.7-linux-x86_64.egg/numpy/core/numeric.py", line 1936, in allclose return all(less_equal(abs(x-y), atol + rtol * abs(y))) ValueError: operands could not be broadcast together with shapes (3) (4)
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Sun, Dec 2, 2012 at 3:16 PM, Ralf Gommers <ralf.gommers@gmail.com> wrote:
On Fri, Nov 30, 2012 at 9:07 AM, Martin Raspaud <martin.raspaud@smhi.se> wrote:
Hi,
We noticed that comparing arrays of different shapes with allclose doesn't work anymore in numpy 1.6.2.
Is this a feature or a bug ? :)
I vote for feature. Allclose does element-wise comparison, so using different size non-broadcastable inputs is an error in user code. It should have raised ValueError in 1.6.1 also.
I think I agree... in retrospect maybe we should have left the change for 1.7 rather than 1.6.2, but it's too late to do much about that, at least for this particular issue. -n
participants (3)
-
Martin Raspaud -
Nathaniel Smith -
Ralf Gommers