Skip to content

Fix and enhance utils.model diagnostics part 3#959

Open
henrydingliu wants to merge 13 commits into
mainfrom
fix-and-enhance-utils.model_diagnostics-part-3
Open

Fix and enhance utils.model diagnostics part 3#959
henrydingliu wants to merge 13 commits into
mainfrom
fix-and-enhance-utils.model_diagnostics-part-3

Conversation

@henrydingliu

@henrydingliu henrydingliu commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

fixing bug on latest
adding support for predicted triangles
adding more tests
simplifying some existing tests

Related GitHub Issue(s)

Additional Context for Reviewers

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)

Note

Medium Risk
Changes diagnostic outputs (Latest/IBNR) that downstream users may rely on, though behavior is now aligned with ultimate and latest diagonal; scope is limited to a utility helper plus tests.

Overview
model_diagnostics is updated so Latest and IBNR line up with triangle semantics: loss data is always taken through cum_to_incr() (replacing the prior incr_to_cum() path when not grouping), and IBNR is Ultimate − Latest instead of obj.ibnr_. The helper also accepts a fitted/predicted Triangle, rejects inputs without ultimate_ / ibnr_ / ldf_, and documents Triangle | MethodBase | Pipeline in its signature.

Tests add np.allclose checks that model_diagnostics matches latest_diagonal and ultimate_ on fit and predict across several estimators, a groupby parity test on prism, and a ValueError when passing a raw triangle; a few predict tests are simplified (fixtures, sample-weight expectations, clrd ordering).

Reviewed by Cursor Bugbot for commit fd8af0b. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.05%. Comparing base (cdd8371) to head (fd8af0b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #959      +/-   ##
==========================================
+ Coverage   88.96%   89.05%   +0.09%     
==========================================
  Files          89       89              
  Lines        5100     5072      -28     
  Branches      663      650      -13     
==========================================
- Hits         4537     4517      -20     
+ Misses        417      415       -2     
+ Partials      146      140       -6     
Flag Coverage Δ
unittests 89.05% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant