DOCS: Expand Triangle constructor examples (#704)#714
Merged
kennethshsu merged 1 commit intocasact:mainfrom Apr 29, 2026
Merged
Conversation
Adds docstring examples covering index, origin_format, development_format, cumulative=False, and trailing. Reformats the two existing examples to match Polars-style doctest conventions: no imports, "..." continuations, and strict output indentation. Also corrects the trailing parameter description in the Parameters section, which previously described .grain() method behavior rather than the constructor's actual behavior (fiscal period-end inference per chainladder.core.base._get_grain). All six examples validated with doctest.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #714 +/- ##
=======================================
Coverage 85.12% 85.12%
=======================================
Files 85 85
Lines 4909 4909
Branches 629 629
=======================================
Hits 4179 4179
Misses 521 521
Partials 209 209
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:
|
This was referenced Apr 24, 2026
This was referenced Apr 25, 2026
kennethshsu
approved these changes
Apr 29, 2026
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.
Addresses #704 for the
Triangleclass constructor.What's in this PR
Adds docstring examples for the previously-undocumented constructor parameters:
index(multi-dimensional Triangle split by a grouping column)origin_formatanddevelopment_format(parsing non-standard date strings)cumulative=False(incremental Triangle)trailing(with side-by-sideTruevsFalsecomparison)Reformats the two existing examples (seeded by #700) to a consistent Polars-style doctest convention within this class:
importstatements (assumed imported per kennethshsu's review feedback on DOCS: Begin work on examples. #700)...continuation prefixes for multi-line statements>>>lines (strict doctest format)Correction to the
trailingparameter descriptionWhile researching how
trailingactually behaves at the constructor level, I found that the existing parameter description matched the behavior of the.grain()method, not the constructor. The constructor'strailingflag controls fiscal-period-end inference (seechainladder/core/base.py::_get_grain):trailing=False: December is treated as the period end (calendar fiscal periods).trailing=True: period end is inferred from the data itself.The Parameters section has been updated to match the constructor's actual behavior. The
.grain()method's own docstring, which describes the partial-period reshuffling, is unchanged.Validation
All six examples were executed against the docstring with Python's
doctestmodule in strict mode (noNORMALIZE_WHITESPACE). All 20 interactions pass with byte-exact output comparison.Scope
This PR covers only the Triangle class constructor. The method-level examples (per #704's standard of one example per parameter for each method) are out of scope and will land in follow-up PRs.
Note
Low Risk
Low risk: changes are documentation/doctest-only, with no runtime logic modifications; main risk is minor confusion if examples drift from actual output over time.
Overview
Improves the
Triangleconstructor documentation by reformatting existing doctest examples and adding new ones that demonstrateindex-based grouping, customorigin_format/development_formatparsing, and building incremental triangles viacumulative=False.Corrects the
trailingparameter description to match constructor behavior (period-end inference vs. partial-period reshuffling) and adds side-by-side doctest examples showingtrailing=Falsevstrailing=Trueoutput.Reviewed by Cursor Bugbot for commit 26c9baf. Bugbot is set up for automated code reviews on this repo. Configure here.