docs: add doctest examples for correlation classes#844
Conversation
Adds Sphinx doctest Examples sections to DevelopmentCorrelation and ValuationCorrelation. Each example opens with the Mack chain-ladder assumption being tested, prints the full decision signal (statistic, confidence band, and boolean) rather than a single boolean, and ties the result back to the chain-ladder workflow. Refs casact#704
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #844 +/- ##
==========================================
+ Coverage 85.12% 86.94% +1.81%
==========================================
Files 85 86 +1
Lines 4909 4994 +85
Branches 629 644 +15
==========================================
+ Hits 4179 4342 +163
+ Misses 521 462 -59
+ Partials 209 190 -19
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:
|
| reserving practice). ``ValuationCorrelation`` flags any diagonal on | ||
| which the split of high versus low link ratios is unlikely under random | ||
| ordering, and can be evaluated per-diagonal (``total=False``, Mack 1997) | ||
| or for the whole triangle (``total=True``, Mack 1993). |
There was a problem hiding this comment.
can move this line between per-diagonal test and total test
There was a problem hiding this comment.
Good catch, moving it between the two blocks so the intro stays scoped to the concept and the total=True form is introduced where it actually runs. Pushed as 3d827d9.
|
thanks for putting this together. there's actually no longer any examples with developmentcorrelation in the doc. so this was much needed. just one small nitpick |
Per @henrydingliu review on casact#844: opening paragraph now scoped to the calendar-effect concept; the per-diagonal vs whole-triangle distinction is introduced as a transition between the two testcode blocks. Refs casact#704
Adds Sphinx doctest
Examplessections to theDevelopmentCorrelationandValuationCorrelationclasses.Refs #704 (Development Pattern Estimators →
DevelopmentCorrelationandValuationCorrelationrows).Summary of Changes
Examplesblock toDevelopmentCorrelationinchainladder/core/correlation.py.Examplesblock toValuationCorrelationin the same file.DevelopmentCorrelationexample:t_expectation, both ends ofconfidence_interval, and thet_criticalboolean — so the reader sees0.0696sitting inside(-0.1275, 0.1275)and understands why the test does not reject independence.ValuationCorrelationexample:testcodeblock fortotal=False(Mack 1997) printing the per-diagonalz_criticalmatrix.testcodeblock fortotal=True(Mack 1993) printing the whole-trianglezand boolean (14.0,False).All numeric outputs use
round(float(...), 4)(same pattern as #836) so the doctest is stable across numpy versions and array backends. Docstring-only; no runtime logic or public API changes.Related GitHub Issue(s)
Additional Context for Reviewers
Doctest CI passed locally.
pytest chainladder/core/tests -x -q→ no regressions.Drafted against the four-point rubric @henrydingliu posted on API Reference Examples #704 / More robust PR template and contributing guidelines #827: each example opens with a practical chain-ladder assumption check, stays consistent with Mack 1993 / 1997, points to the existing Mack section of the user guide rather than duplicating it, and prints the full decision signal (statistic, confidence band, boolean) rather than a single boolean.
Intentionally excludes
.github/workflows/sync-main-to-docs.yml, matching the split-PR convention from docs: add tail estimator doctest examples #801 and docs: add BootstrapODPSample doctest examples #836.Happy to also embed a worked
MackChainladdercall inside the example if reviewers want the chain-ladder tie-in to be more concrete — left out here to keep the PR small.I passed tests locally for both code (
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Low Risk
Docstring and doctest narrative only; no executable code or API behavior changes.
Overview
Documentation only for
ValuationCorrelationincorrelation.py: the SphinxExamplessection is tightened so the opening text no longer mixes per-diagonal and whole-triangle modes in one sentence.A short bridge paragraph now introduces the second doctest block, explaining that the same calendar-effect check can run as per-diagonal (
total=False, Mack 1997) or whole-triangle (total=True, Mack 1993) before the existingtotal=Trueexample that prints aggregatedzandz_critical.No changes to correlation logic, parameters, or public API—only how reviewers read the worked examples.
Reviewed by Cursor Bugbot for commit 3d827d9. Bugbot is set up for automated code reviews on this repo. Configure here.