[Numpy-discussion] assert_almost_equal bug?
Ralf Gommers
ralf.gommers at googlemail.com
Sat Mar 12 07:16:38 EST 2011
On Sat, Mar 12, 2011 at 12:10 AM, Keith Goodman <kwgoodman at gmail.com> wrote:
> assert_almost_equal() and assert_array_almost_equal() raise a
> ValueError instead of an AssertionError when the array contains
> np.inf:
That's a bug, is fixed in 45269ee1. assert_array_compare was checking
for nans but not for infs.
Cheers,
Ralf
>
>>> 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
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list