[Numpy-discussion] assert_almost_equal bug?

Keith Goodman kwgoodman@gmail....
Fri Mar 11 10:10:09 CST 2011


assert_almost_equal() and assert_array_almost_equal() raise a
ValueError instead of an AssertionError when the array contains
np.inf:

>> a = np.array([[1., 2.], [3., 4.]])
>> b = a.copy()
>> np.testing.assert_almost_equal(a, b)
>> b[0,0] = np.inf
>> np.testing.assert_almost_equal(a, b)
<snip>
ValueError:
Arrays are not almost equal
 x: array([[ 1.,  2.],
       [ 3.,  4.]])
 y: array([[ inf,   2.],
       [  3.,   4.]])
>> np.testing.assert_array_almost_equal(a, b)
<snip>
ValueError:
Arrays are not almost equal
 x: array([[ 1.,  2.],
       [ 3.,  4.]])
 y: array([[ inf,   2.],
       [  3.,   4.]])

ticket: http://projects.scipy.org/numpy/ticket/1769


More information about the NumPy-Discussion mailing list