Let's see the
assert_array_almost_equal_nulp
function in action:
finfo
function:eps = np.finfo(float).eps print "EPS", eps
The epsilon would be:
EPS 2.22044604925e-16
1.0
with 1 +
epsilon (eps
) using the assert_almost_equal_nulp
function. Do the same for 1 + 2 *
epsilon (eps
):print "1", np.testing.assert_array_almost_equal_nulp(1.0, 1.0 + eps) print "2", np.testing.assert_array_almost_equal_nulp(1.0, 1.0 + 2 * eps)
The result:
1 None 2 Traceback (most recent call last): … assert_array_almost_equal_nulp raiseAssertionError(msg) AssertionError: X and Y are not equal to 1 ULP (max is 2)