-
Notifications
You must be signed in to change notification settings - Fork 9
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
Resolve clippy warnings and errors #45
Conversation
@@ -842,7 +849,7 @@ impl Geodesic { | |||
} | |||
|
|||
let alp12: f64; | |||
if !meridian && comg12 > -0.7071 && sbet2 - sbet1 < 1.75 { | |||
if !meridian && comg12 > -FRAC_1_SQRT_2 && sbet2 - sbet1 < 1.75 { |
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.
I understand why you're doing this, but it diverges from our reference implementation whose test suite we validate against.
The tests seem to all still be passing, which makes me wonder if this edge case is maybe not tested too precisely. It could be a real pain to track down later if the tests input changes to test around this more precisely.
Still, your proposed change feels like the right thing to do. Could you add a comment to the effect of:
we're diverging from Karney's implementation here which uses the hardcoded constant: -0.7071 for FRAC_1_SQRT_2
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.
I had the same doubts seeing this suggestion from Clippy. But I decided that it is beneficial to do that because use of internal constant improves code readability and has an explicit type.
This edge case might indeed not be tested precisely enough. Actually, probability for hitting a different branch in Rust implementation than in original implementation is very low: difference between constants is roughly -6.78e-6
and there are two other conditions alongside.
And the constant -0.7071
is present only in Karney's implementation but not in the reference paper. So it seems like its use is an implementation shortcut.
I've added the requested change.
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.
One comment nit, but otherwise, LGTM, thanks!
I've also added a few common trait implementations using |
The derived There are so many parameters in that struct, many which have a particular relationship. It seems extremely unlikely that anything reasonable could be made by having them all equal 0, as the derived implementation does. |
I'm sorry, my oversight. I've removed the |
Thanks! |
CHANGES.md
if knowledge of this change could be valuable to users.This PR solves all Clippy warnings and errors present in the codebase. It also silences Clippy warnings that I evaluated as false-positives (eg.
excessive_precision
) or that required too significant changes (eg.too_many_arguments
).Changes do not seem to have any significant impact on the performance, but they solve some issues mentioned in #32 so this PR may be a start towards performance improvement.
The PR is split into so many commits for easier review, but it should probably be stashed after the review.