docs: fix DevelopmentConstant patterns dict in friedland chapter_8#897
Draft
SaguaroDev wants to merge 1 commit into
Draft
docs: fix DevelopmentConstant patterns dict in friedland chapter_8#897SaguaroDev wants to merge 1 commit into
SaguaroDev wants to merge 1 commit into
Conversation
…asact#890) The final cell of docs/friedland/chapter_8.ipynb passed a nested {'reported': {...}, 'paid': {...}} dict to DevelopmentConstant, but the non-callable patterns path expects a flat {age: value} dict (per the docstring). fit() did self.patterns[12] against the top-level keys and raised KeyError, failing the Doctest CI job (execution_mode='force'). Pass patterns['paid'] in the fit cell since it fits auto_bi['Paid Claims']. The nested definition is kept for the preceding pedagogical cell. Verified the notebook now executes end-to-end with no CellExecutionError.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #897 +/- ##
=======================================
Coverage 86.90% 86.90%
=======================================
Files 87 87
Lines 4932 4932
Branches 624 624
=======================================
Hits 4286 4286
Misses 456 456
Partials 190 190
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:
|
Collaborator
|
kenneth is actively working on this. this may conflict with his complete version. mind keeping this as draft for now? |
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.
What
The final code cell of
docs/friedland/chapter_8.ipynberrors during the docs build, failing the Doctest CI job:Why
patternsis defined as a nested dict:But the non-callable
patternspath inDevelopmentConstant.fit(and the docstring: "A dictionary key:value representation of age(in months):value") expects a flat{age: value}dict.fitindexesself.patterns[item]for eachiteminobj.ddims([12, 24, ...]), so with the nested dict it looks uppatterns[12]and raisesKeyError.Fix
Pass the
'paid'sub-dict in the fit cell, since it fitsauto_bi["Paid Claims"]. The nestedpatternsdefinition is left intact for the preceding cell (which shows the full reported+paid pattern set). One-line change to the notebook source.Verification
Executed the notebook end-to-end locally (
jupyter nbconvert --execute, 120s timeout) — it now completes with noCellExecutionError, and the fit cell produces a cleanexecute_resultwith the expected LDFs (12-24: 6.0,24-36: 3.0, ... matching the Friedland exhibit).The bug is present on both
mainandexperimental; targetingmain.Note
Low Risk
Documentation-only notebook one-liner; no library or production code paths change.
Overview
Fixes a docs notebook cell that broke Doctest / nbconvert execution: the Friedland chapter 8 example passed the full nested
patternsdict intoDevelopmentConstant.fiton Paid Claims, but the non-callablepatternspath indexes{age_in_months: value}directly (self.patterns[item]for eachobj.ddimsentry), which raisedKeyError: 12.The change passes
patterns['paid']so the fit uses the paid CDF pattern that matchesauto_bi["Paid Claims"], while the earlier cell can still display the nested reported+paid pattern set.Reviewed by Cursor Bugbot for commit de9b0dc. Bugbot is set up for automated code reviews on this repo. Configure here.