Skip to content

[FIX] Raise when a DevelopmentConstant pattern has several rows or columns - #1644

Open
scks1 wants to merge 1 commit into
casact:mainfrom
scks1:#1642-constant-pattern-shape
Open

scks1 wants to merge 1 commit into
casact:mainfrom
scks1:#1642-constant-pattern-shape

Conversation

@scks1

@scks1 scks1 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

DevelopmentConstant now raises a ValueError when a Triangle or fitted-estimator pattern has more than one index row or more than one column. Before, _normalize_patterns read only patterns.values[0, 0, 0, :] and applied that one pattern to every row and column of the triangle being fit, with no warning. The error message points to a callable with callable_axis for patterns that vary by row or column, and the patterns docstring now says the same.

test_constant_pattern_with_several_index_rows_or_columns fits Development to clrd summed by LOB, with paid and incurred losses. It checks that ldf_, the fitted estimator, a one-column slice with six lines and a one-line slice with two columns all raise, and that a pattern with one line and one column still applies to all six lines. It fails on main, where nothing raises.

Related GitHub Issue(s)

Closes #1642

AI/LLM Usage

This change was made with Árbol, an AI assistant running on Muse, working under my direction. It found the bug, wrote the change and the test, ran the checks below and drafted this description.

Additional Context for Reviewers

Every other DevelopmentConstant call on main passes a dict or a callable: the library (CaseOutstanding), the tests, the Friedland chapters, the user guide and the gallery. So none of them reach the new check. The open Friedland PRs #1220 and #1327 also pass dicts.

#1304 edits the lines just above and below the new check. Git merges this branch with #1304's head 4559f5c with no conflict in constant.py or test_constant.py. With this commit applied on top of 4559f5c, all 38 tests in test_constant.py pass.

On this branch, 233 tests pass across chainladder/development, test_exponential.py, test_capecod.py and test_triangle.py::test_single_entry, the last three because they also use DevelopmentConstant. ruff check and format are clean on the changed files.

Submitter's Checklist

  • I have reviewed and am adhering to the standards outlined in the project Governing Doc.
  • The PR subject title summarizes the changes, with one proper prefix ([FIX], [FEAT], [DOCS], [TST], [CHORE], or [BRK]).
  • I am a human (not a bot), and this PR form is written by a human.

Reviewer's Checklist

  • The implementation addresses the associated issue(s).
  • The implementation is appropriate, maintainable, and follows ARCHITECTURE.md.
  • PR subject title has the proper prefix and the subject is appropriate.
  • Relevant issue(s) are linked.
  • AI/LLM usage is disclosed and appropriate.
  • Documentation and tests are appropriate.
  • CI tests passed, or any failures are acceptable.
  • Leave a comment with the final recommendation (e.g. approve as is, request a secondary review, or flag an area for more review).

_normalize_patterns read only patterns.values[0, 0, 0, :], so a Triangle
or fitted estimator holding one pattern per line of business or per
measure gave every line and measure the first one's pattern, with no
warning. It now raises a ValueError that points to the callable route.

Fixes casact#1642

Developed with an AI assistant (Árbol, running Muse).
@github-actions

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 18.1% of exported symbols fully typed (303 / 1677)

Known Ambiguous Unknown Total
Project (head) 303 96 1278 1677

Other symbols referenced but not exported by chainladder: 24

Known Ambiguous Unknown Total
Other (head) 11 1 12 24

Symbols without documentation:

  • Functions without docstring: 331
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 0.0% fully typed (0 / 1)

Known Ambiguous Unknown Total
Patch 0 0 1 1
Patch symbol details
Symbol Status Change
chainladder.development.tests.test_constant.test_constant_pattern_with_several_index_rows_or_columns ❌ unknown new

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (8d8f90c) to head (7958e1a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1644   +/-   ##
=======================================
  Coverage   95.00%   95.00%           
=======================================
  Files         100      100           
  Lines        6460     6462    +2     
  Branches      819      820    +1     
=======================================
+ Hits         6137     6139    +2     
  Misses        204      204           
  Partials      119      119           
Flag Coverage Δ
unittests 95.00% <100.00%> (+<0.01%) ⬆️

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.

[BUG] DevelopmentConstant gives every index row and column the first one's pattern

1 participant