-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
(feat) improve rss_errors()
using a functional programming approach
#177
(feat) improve rss_errors()
using a functional programming approach
#177
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #177 +/- ##
==========================================
+ Coverage 66.33% 66.49% +0.15%
==========================================
Files 127 127
Lines 32445 32455 +10
==========================================
+ Hits 21524 21580 +56
+ Misses 10921 10875 -46
☔ View full report in Codecov by Sentry. |
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.
We can add some unit tests for sure. At the moment, these two functions are used in the propagator when we're using an adaptive time step, so they're frequently hit. The results of the propagators exactly match GMAT, so I'm pretty confident that they're correct and that any new bug in those functions would be caught immediately.
If you want to add units tests, I wrote a quick example of different common ways to initialize a vector using nalgebra: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=00f15985f45e6c43e3ab1469bd310cb3 .
v += (prop_err[i] - cur_state[i]).powi(2); | ||
} | ||
v.sqrt() | ||
prop_err |
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.
Good idea! I initially seem to have written this in April 2018 (the 2021 commit is got a change in nalgebra), and that was before I used any FP in Rust.
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 added the UT based on the way you created OVector in the code snippet you shared.
src/utils.rs
Outdated
/// | ||
/// # Returns | ||
/// | ||
/// * A f64 value representing the RSS state error. |
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.
/// * A f64 value representing the RSS state error. | |
/// A f64 value representing the RSS state error. |
(minor) I don't think we need this to be a bullet point
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.
Done.
src/utils.rs
Outdated
/// | ||
/// # Returns | ||
/// | ||
/// * A tuple of f64 values representing the RSS orbit errors in radius and velocity. |
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.
/// * A tuple of f64 values representing the RSS orbit errors in radius and velocity. | |
/// A tuple of f64 values representing the RSS orbit errors in radius and velocity. |
(minor) idem
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.
Done.
src/utils.rs
Outdated
/// | ||
/// # Returns | ||
/// | ||
/// * A tuple of f64 values representing the RSS orbit vector errors in radius and velocity. |
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.
/// * A tuple of f64 values representing the RSS orbit vector errors in radius and velocity. | |
/// A tuple of f64 values representing the RSS orbit vector errors in radius and velocity. |
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.
Done.
rss_*
utility functions fromutils.rs
rss_errors
kind of more idiomatic using a functional programming wayI tried to put some UT but I did not well understood how to do them.
For example, we could have:
But I currently have some compiler complains about
from_vec
, so I gave up and trust the CI.I hope to get feedback from you on this subject!