-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Float arrays' comparisons in tests #4400
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
Comments
The "are" link is actually "almost" ;) We should use I am very certain that 2. is the way to go. And 229 lines are not that bad. I am quite sure that we are in not too bad a shape, and most uses of |
@amueller I got 229 not by |
Ah. I grepped and got ~700. |
I share @amueller's position on that matter. |
Attempt to deal with scikit-learn#4400
A recent issue indicated a flaw in many of sklearn's tests: there are many places where arrays are compared using
assert_array_equal
which does not take float's lack of precision into account.Sometimes, though, we might expect a tested functionality to return exactly the same value — when checking, say,
predict
. It seems legitimate to use strict comparison in those cases.Even though apparently this is not a problem at the moment (at least no one filed a bunch of bug reports like the one I mentioned), we might want to do something with it. Some of the possible fixes are:
assert_array_equal
to use approximate comparison in case of floating data type. Might break guarantees like "predict
returns the same values that were passed iny
".assert_array_equal
withassert_array_almost_equal
when appropriate. This is a huge body of work, there are at least 229 tests that compare float arrays usingassert_array_equal
.The text was updated successfully, but these errors were encountered: