Skip to content

DOCS: Expand Triangle constructor examples (#704)#714

Merged
kennethshsu merged 1 commit intocasact:mainfrom
EKtheSage:docs/issue-704-triangle-constructor-examples
Apr 29, 2026
Merged

DOCS: Expand Triangle constructor examples (#704)#714
kennethshsu merged 1 commit intocasact:mainfrom
EKtheSage:docs/issue-704-triangle-constructor-examples

Conversation

@EKtheSage
Copy link
Copy Markdown
Contributor

@EKtheSage EKtheSage commented Apr 24, 2026

Addresses #704 for the Triangle class 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_format and development_format (parsing non-standard date strings)
  • cumulative=False (incremental Triangle)
  • trailing (with side-by-side True vs False comparison)

Reformats the two existing examples (seeded by #700) to a consistent Polars-style doctest convention within this class:

  • Removed import statements (assumed imported per kennethshsu's review feedback on DOCS: Begin work on examples. #700)
  • Added ... continuation prefixes for multi-line statements
  • Indented output at the same base level as >>> lines (strict doctest format)

Correction to the trailing parameter description

While researching how trailing actually behaves at the constructor level, I found that the existing parameter description matched the behavior of the .grain() method, not the constructor. The constructor's trailing flag controls fiscal-period-end inference (see chainladder/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 doctest module in strict mode (no NORMALIZE_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 Triangle constructor documentation by reformatting existing doctest examples and adding new ones that demonstrate index-based grouping, custom origin_format/development_format parsing, and building incremental triangles via cumulative=False.

Corrects the trailing parameter description to match constructor behavior (period-end inference vs. partial-period reshuffling) and adds side-by-side doctest examples showing trailing=False vs trailing=True output.

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

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
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.12%. Comparing base (6ea3577) to head (26c9baf).
⚠️ Report is 2 commits behind head on main.

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           
Flag Coverage Δ
unittests 85.12% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@kennethshsu kennethshsu merged commit a0441b2 into casact:main Apr 29, 2026
8 checks passed
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.

2 participants