-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG:change formatting of assert_array_almost_equal #4541
Conversation
LGTM. Needs some tests, probably in |
Sounds good to me, when I checked I couldn't find test cases for any of the three functions ( |
Some areas of Numpy are under tested. I'd say add a test |
assert_array_almost_equal now prints the number of digits that were being compared in the test instead of always printing 8 (the default for array_repr). This would lead to uninformattive error messages. Fixes numpy#2367
@charris that sounds good to me, I'll add those for |
On a second look, I think only |
For the tests themselves, it might be easier to parse out the numbers and just compare those rather than the complete strings. Could maybe have a small function to do that. |
Ah, now I get it, thanks! I'll try to add those. |
This check is needed now that build_err_msg takes a precision argument, which is only relevant if the things being compared are ndarrays.
assert_approx_equal & assert_almost_equal make internal use of build_err_msg so a few tests have been added to check that the errors are formatted correctly.
It's silly to check scalars when their string representations will vary so much from system to system.
The tests were looking at the formatting of other elements in the string which is not relevant for the things testsed in this case. By looking only at the array formatting, we guarantee consistency across systems.
@charris I've added some other tests and added a check in |
BUG:change formatting of assert_array_almost_equal
Merged, thanks @ElDeveloper. |
Thanks for the pointers @charris. |
thanks, the now fixed behavior has always bothered me when looking at test failures logs due to rounding issues |
assert_array_almost_equal
now prints the number of digits that werebeing compared in the test instead of always printing 8 (the default
for
array_repr
). This would lead to uninformattive error messages.Fixes #2367