[Numpy-discussion] commutative allclose

Tom Johnson tjhnson@gmail....
Thu Apr 10 14:56:44 CDT 2008

Should allclose() be commutative, so as to prevent the following:

>>>  x = 1.00001001
>>> allclose(x,1), allclose(1,x)
(False, True)

There is some discussion here which provides two possible solutions:


Notice, the discussion states that their solutions are not
transitive---nevertheless, I think commutativity is a worthwhile
improvement.  Also, they mention that rtol * abs(y) can cause
underflow issues.  Thus, they implement,

|x-y|/|y| <= rtol     AND(OR)     |x-y|/|x| <= rtol

without an atol option, rather than

|x-y| <= atol + rtol* |y|

Naively, it seems like atol is attempting to correct this very issue.
So do we really need atol?

More information about the Numpy-discussion mailing list