ENH: Make assert_almost_equal & assert_array_almost_equal consistent.#7760
ENH: Make assert_almost_equal & assert_array_almost_equal consistent.#7760charris merged 1 commit intonumpy:masterfrom
Conversation
|
Will add release note. |
|
Note that this leads to errors in scipy of the sort Which is a valid failure, but the previous version let it pass. |
numpy/testing/utils.py
Outdated
There was a problem hiding this comment.
If decimal is a numpy int, this might start giving zero division errors in the future... 😈
There was a problem hiding this comment.
Only after a deprecation period, and of course it would get fixed before the deprecation could land anyway...
e11136d to
822ef7c
Compare
|
Hmm, I had a failure for |
|
Note that this only differs from #6601 in using EDIT: No longer the case. |
822ef7c to
10b36d4
Compare
|
Wait, I can do better... |
10b36d4 to
ba2a803
Compare
|
OK, I think I'm done with this... |
ba2a803 to
3883690
Compare
numpy/testing/utils.py
Outdated
There was a problem hiding this comment.
Would making this <= still make sense and remove the possibly stronger tests? Not sure if that makes sense or not. Anyway, looks good to me.
I would like to nudge you towards adding a test ;p. Wondering if we can somehow make it easier to understand what "decimal" means in the documentation. Also "vagaries" seems a bit difficult to me as a non-native speaker, maybe "details"?
There was a problem hiding this comment.
I had that, but changed it on account of
nt.assert_almost_equal([1.5], [0], decimal=0)
failing in master due to rounding the difference 1.5 up. Note that
nt.assert_almost_equal([1.49999], [0], decimal=0)
does pass (just to assure everyone the 1.5 is the proper factor).
There was a problem hiding this comment.
Can't make everything exactly the same, but I figure that any problems are in tests too close to the edge in any case.
There was a problem hiding this comment.
Yeah need a test. If there had been one in the first place we would never have ended up with 1.5 * 10**(-decimal). That was due to the use of a <= instead of <, and I think that came about from working around some other perceived bug. I'd just change it if it didn't cause so many new failures in downstream code.
This changes the check for scalars in assert_almost_equal so that
abs(actual - desired) < 1.5 * 10**(-decimal)
Note that the previous documentation claimed that the functions were
equivalent to
abs(actual - desired) < .5 * 10**(-decimal)
but that was not how they behaved in practice.
Due to the change in implementation, some very delicate tests may fail
that did not fail before. No extra failures were noted in scipy.
Closes numpy#5200.
3883690 to
55002a5
Compare
|
Looks all OK to me. |
This changes the check for scalars in assert_almost_equal so that
Note that the previous documentation claimed that the functions were
equivalent to
but that was not how they behaved as implemented.
Some very delicate tests may fail that did not fail before but no new failures were seen in
SciPy version 0.18.0.dev0+8346eea.Closes #5200.