Skip to content

Const#878

Merged
henrydingliu merged 2 commits into
casact:#864_alt_impfrom
henrydingliu:const
May 29, 2026
Merged

Const#878
henrydingliu merged 2 commits into
casact:#864_alt_impfrom
henrydingliu:const

Conversation

@henrydingliu
Copy link
Copy Markdown
Collaborator

@henrydingliu henrydingliu commented May 29, 2026

Summary of Changes

a different implementation, keeping more of the original code

Related GitHub Issue(s)

closes #864

Additional Context for Reviewers

using tests from #868, but with some updates

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)

Note

Medium Risk
Changes reserve development factor fitting used downstream in reserving; behavior shifts for short/long/missing pattern keys but is heavily test-covered.

Overview
DevelopmentConstant now applies dict-based external patterns when ages do not line up one-to-one with the triangle’s development periods.

For dict patterns, ages beyond the triangle’s maximum development are appended to ddims and the value array is extended on the last axis. Ages without an entry default to 1.0 via patterns.get(item, 1) instead of requiring every key. Callable patterns and whitespace-only cleanup are unchanged.

Tests were added (and one file newline fixed) for short vs long pattern dicts, CDF vs LDF, optional tail ages, and incremental triangles—covering issue #864 behavior.

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

@henrydingliu henrydingliu merged commit 3eb7cc7 into casact:#864_alt_imp May 29, 2026
8 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5180fdb. Configure here.

extra_dims = [x for x in self.patterns.keys() if x > np.max(obj.ddims)]
if extra_dims:
obj.values = xp.concatenate([obj.values]+[obj.iloc[...,-1:].values]*len(extra_dims), -1)
obj.ddims = np.concatenate((obj.ddims, extra_dims), 0,)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsorted extra_dims causes incorrect development pattern ordering

Medium Severity

extra_dims is built from self.patterns.keys() and preserves dictionary insertion order, but is never sorted before being concatenated to obj.ddims. If a user provides pattern keys in non-ascending order (e.g., {132: 1.1, 120: 1.1, ...}), the resulting obj.ddims will be out of order. This corrupts the CDF-to-LDF conversion (ldf[..., :-1] / ldf[..., 1:]) since it relies on consecutive development periods being in ascending order, leading to silently incorrect actuarial results.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5180fdb. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.09%. Comparing base (449b5c1) to head (5180fdb).

Additional details and impacted files
@@               Coverage Diff                @@
##           #864_alt_imp     #878      +/-   ##
================================================
+ Coverage         87.04%   87.09%   +0.05%     
================================================
  Files                86       86              
  Lines              4986     4991       +5     
  Branches            646      647       +1     
================================================
+ Hits               4340     4347       +7     
+ Misses              456      455       -1     
+ Partials            190      189       -1     
Flag Coverage Δ
unittests 87.09% <100.00%> (+0.05%) ⬆️

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.

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.

1 participant