-
Notifications
You must be signed in to change notification settings - Fork 839
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
Fix clippy lint clippy::float_equality_without_abs
#1305
Fix clippy lint clippy::float_equality_without_abs
#1305
Conversation
This float comparison with epsilon hint is a pet peeve of mine. The epsilon should not be needed if we expect a result that can be exactly represented in a float. I think the corresponding |
Codecov Report
@@ Coverage Diff @@
## master #1305 +/- ##
==========================================
+ Coverage 83.01% 83.05% +0.03%
==========================================
Files 180 180
Lines 52731 52824 +93
==========================================
+ Hits 43775 43873 +98
+ Misses 8956 8951 -5
Continue to review full report at Codecov.
|
@jhorstmann to be clear, would you prefer that we keep the module level Or perhaps annotate the individual tests with
Or something else? |
It's also possible to allow only in the tests #![cfg_attr(test, allow(clippy::float_equality_without_abs))] but I'm actually curious how would you do the check without epsilon. |
My suggestion was to remove the
with
where the asserted number can be exactly represented in floating point and where the operation does not involve any rounding. In some earlier rust version the latter assertion would have triggered the |
@jhorstmann thanks for the explanation, I'm going to update the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thank you @gsserge and @jhorstmann
clippy::float_equality_without_abs
Which issue does this PR close?
This is part of #1255
Rationale for this change
It's beneficial to run clippy as strict as possible.
What changes are included in this PR?
This PR enables
clippy::float_equality_without_abs
lint in thearrow
crate and fixes all the relates testing code for this check to pass.Are there any user-facing changes?
No.