Fix basic math calls when TMB defined#946
Conversation
Instructions for code reviewerHello reviewer, thanks for taking the time to review this PR!
Checklist
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #946 +/- ##
==========================================
- Coverage 80.26% 75.18% -5.09%
==========================================
Files 51 82 +31
Lines 1941 8414 +6473
Branches 461 461
==========================================
+ Hits 1558 6326 +4768
- Misses 262 1981 +1719
+ Partials 121 107 -14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
How I tracked this down: I ran into an R session crash when trying to run tests in the surplus production branch. I used gdb backtrace to isolate the line of code in fims_math that was throwing the error. I then used a Gemini query to come up with the solution that was implemented. |
|
Thanks @Andrea-Havron-NOAA for finding this and explaining your path for working on it. I am thinking though that this should go to main rather than dev if the model is crashing. @msupernaw what do you think about the changes, are they sustainable for other engines besides TMB? |
|
@msupernaw when you are back from 🏖️ can you please review this PR so we can get it out has a hot fix? Thank you. |
4174303 to
d02c61f
Compare
|
@Andrea-Havron-NOAA I force pushed because I reset the base branch to main and cherry-picked your commit. |
d02c61f to
beaac79
Compare
beaac79 to
ea27ecb
Compare
What is the feature?
exp()and other basic math functions. This has to do with howexp()was referenceing the global namespace. This worked when CppAD was defined because CppAD has anexp()and other basic math functions in the global namespace while TMBad does not. This PR fixes the issue by involking an Argument-Dependent Lookup instead of relying on the global namespace.How have you implemented the solution?
using ::exp;and replaced withusing std::exp;This solution now initially looks for the type in std. If it is not found, it will search in other libraries for specialized versions of the function with the specific type defined.
Does the PR impact any other area of the project, maybe another repo?