feat: create a warning when fitted parameter is at the bounds#2526
Open
kratsg wants to merge 6 commits into
Open
feat: create a warning when fitted parameter is at the bounds#2526kratsg wants to merge 6 commits into
kratsg wants to merge 6 commits into
Conversation
071c32a to
33c3a54
Compare
350b577 to
61bd40a
Compare
51317ec to
790c148
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2526 +/- ##
=======================================
Coverage 98.28% 98.28%
=======================================
Files 65 65
Lines 4305 4308 +3
Branches 465 467 +2
=======================================
+ Hits 4231 4234 +3
Misses 46 46
Partials 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Clean up the rough draft: unpack (lower, upper) from each bound for clarity, fix to use % style logging rather than f-string, and improve the warning message to include the fitted value and both bound values. Add regression tests for lower bound, upper bound, and interior cases using _internal_postprocess directly with a synthetic OptimizeResult so the check is independent of optimizer floating-point behaviour. Closes #2525 Co-Authored-By: Giordon Stark <kratsg@gmail.com>
…ound check The three TODOs around the at-bounds warning loop are all safe to resolve: batching is not yet implemented (fitresult.x is always 1D), fixed parameters are already excluded because shim() strips them from both fitresult.x and par_bounds before optimization, and the in-tuple comparison is safe across all backends since fitresult.x is always a numpy array from scipy/iminuit. Replace the TODOs with an explanatory comment documenting why the alignment is guaranteed. Co-Authored-By: Giordon Stark <kratsg@gmail.com>
59108a3 to
30b9727
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Resolves #2525.
When nuisance parameters hit their bounds during fitting (e.g. in a large-model toy run), there was previously no indication that this had happened, making it difficult to diagnose suspect fit results. This PR adds a
WARNINGlog message from_internal_postprocesswhenever a fitted parameter lands exactly on a bound, reporting the parameter index, the fitted value, and the bound range.The implementation iterates over the free parameters in
fitresult.xalongside their bounds (both already stripped of fixed parameters byshim()before optimization). Three architectural concerns (batching, fixed-parameter skipping, and backend compatibility) were investigated (using CLAUDE) and confirmed to be non-issues given the current design; a clarifying comment documents why the alignment is guaranteed.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: