Const#878
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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,) |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 5180fdb. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
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:
|


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
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
DevelopmentConstantnow 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 toddimsand the value array is extended on the last axis. Ages without an entry default to 1.0 viapatterns.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.