-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Prevent errors due to unsafe math optimizations #1161
Conversation
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.
Thank for addressing #1155! This looks mostly good to me, and should take care of most concerns from #1155 (I still think that NaN
should be avoided long-term, as not all compilers offer granular control over fast-math options). As an error is in place, closing #1155 via this PR is 👍.
Regarding self.assertNear
vs. self.assertEqual
: equivalent changes probably should be applied across the test suite whenever floats are compared? (which would be a lot of churn, so I'm not exactly advocating for this here.) At the same time, the issues probably only arise here due to the fact that activation energy input requires more processing than other items.
While it's not obvious from the diff alone, the instances I changed are more than just the test cases that failed -- these are the other instances in at least these Python tests where a calculated value was being compared for exact equality (because we go back and forth between Ea/R and E). I didn't go through |
I think those discrepancies of exact bit-wise matches can occur anytime a unit conversion happens. I'm not advocating for large-scale changes (if any beyond what you already changed) in this PR, but it may be safer to avoid exact comparisons for floating point values in general? |
Of course, and I think in general, we do a good job of that. There are just a lot comparisons in the test suite, and it's easy to type |
... guilty as charged! Certainly has happened in some of the tests I wrote. |
This allows the test suite to pass even when using unsafe math optimizations
Codecov Report
@@ Coverage Diff @@
## main #1161 +/- ##
=======================================
Coverage 66.10% 66.10%
=======================================
Files 313 313
Lines 44963 44955 -8
Branches 19144 19137 -7
=======================================
- Hits 29721 29719 -2
+ Misses 12658 12652 -6
Partials 2584 2584
Continue to review full report at Codecov.
|
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.
Thank you, this looks good to me!
This is my proposed resolution to #1155.
Changes proposed in this pull request
std::isnan
, and suggest appropriate compiler flags if this is not the case-ffast-math -fno-finite-math-only
passes the test suiteIf applicable, fill in the issue number this pull request is fixing
Closes #1155
Checklist
scons build
&scons test
) and unit tests address code coverage