Throw runtime error when parameter is set via command line in a range…#1209
Throw runtime error when parameter is set via command line in a range…#1209anigamova merged 3 commits intocms-analysis:mainfrom
Conversation
|
To be discussed before merging |
📝 WalkthroughWalkthroughPost-assignment validation was added in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/utils.cc`:
- Around line 799-806: The code block around
SetParameterExpression/PhysicsParameterValue/tmpParameter (involving
tmpParameter->setVal(...) and the throw std::runtime_error(Form(...))) has
clang-format violations; run the auto-formatter (git-clang-format HEAD~) to
reformat this region so it meets project style rules, then stage the formatted
changes and push; ensure the lines with the cout, tmpParameter->setVal, and the
throw/Form call are reformatted consistently.
🧹 Nitpick comments (1)
src/utils.cc (1)
768-772: Consider extracting a small helper to reduce duplication.Both the regex and direct-assignment paths share the same post-
setValvalidation and error-throwing logic. A small inline helper (or even a lambda) would keep them in sync if the message or logic ever changes.♻️ Example helper extraction
+namespace { + void validateParameterInRange(RooRealVar *param, double requestedVal, const std::string &name) { + if (param->getVal() != requestedVal) { + throw std::runtime_error(Form("Parameter %s value %g is outside its range [%g, %g]. " + "Use --rMin/--rMax or --setParameterRanges to adjust the range.", + name.c_str(), requestedVal, param->getMin(), param->getMax())); + } + } +} // namespaceThen in both call sites:
tmpParameter->setVal(PhysicsParameterValue); - if (tmpParameter->getVal() != PhysicsParameterValue) { - throw std::runtime_error(Form("Parameter %s value %g is outside its range [%g, %g]. " - "Use --rMin/--rMax or --setParameterRanges to adjust the range.", - target.c_str(), PhysicsParameterValue, tmpParameter->getMin(), tmpParameter->getMax())); - } + validateParameterInRange(tmpParameter, PhysicsParameterValue, target);Also applies to: 802-806
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (92.85%) is below the target coverage (98.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1209 +/- ##
==========================================
+ Coverage 20.71% 20.81% +0.09%
==========================================
Files 195 195
Lines 26166 26178 +12
Branches 3924 3926 +2
==========================================
+ Hits 5420 5448 +28
+ Misses 20746 20730 -16
... and 1 file with indirect coverage changes
🚀 New features to boost your workflow:
|
|
Are there any other reason why the |
8de53fa to
bb76461
Compare
… outside its value
bb76461 to
1119797
Compare
… outside its value
Summary by CodeRabbit
Bug Fixes
Tests