fix and enhance utils.model_diagnostics#913
Merged
henrydingliu merged 10 commits intoJun 4, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## #839_model_summary #913 +/- ##
======================================================
+ Coverage 88.16% 88.42% +0.26%
======================================================
Files 87 87
Lines 4952 4969 +17
Branches 629 635 +6
======================================================
+ Hits 4366 4394 +28
+ Misses 443 436 -7
+ Partials 143 139 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 90c4c0a. Configure here.
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.

Summary of Changes
Related GitHub Issue(s)
Additional Context for Reviewers
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Medium Risk
Changes a widely used diagnostics helper and moves shared CDF alignment logic; Benktander now errors without sample_weight, which may break callers that relied on optional weights.
Overview
This PR refactors CDF/LDF vertical alignment into
Triangle.align_pattern(pattern triangles only) and wiresMethodBase._align_cdfthrough it, with a guard test when called on non-pattern triangles.model_diagnosticsis tightened and extended: it now accepts a fittedTriangle,MethodBase, orPipeline, rejects inputs missingultimate_/ibnr_/ldf_, builds diagnostics fromcum_to_incron the model triangle (or the passedTriangle), and whengroupbyis unset addsLDFandCDFcolumns viaalign_pattern.groupbyaggregation forIBNR(and related paths) is adjusted so summarized diagnostics stay consistent with grouped fits.Benktander
fitandpredictnow requiresample_weight, matching other exposure-based estimators. Tests consolidatepredict/ weight validation across estimators and addmodel_diagnosticserror andgroupbyparity coverage.Reviewed by Cursor Bugbot for commit e9d0640. Bugbot is set up for automated code reviews on this repo. Configure here.