Skip to content

[FEAT]deprecate date dims - #1304

Open
priyam0k wants to merge 32 commits into
mainfrom
feature/deprecate-date-dims
Open

priyam0k wants to merge 32 commits into
mainfrom
feature/deprecate-date-dims

Conversation

@priyam0k

@priyam0k priyam0k commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

  • Initialize origin and development on Triangle via TriangleAxis descriptors (axis 2 and 3), centralizing axis storage into Triangle._axes alongside index and columns (incorporates [FEAT] Centralize axis descriptors #1454).
  • Move _set_origin, _get_origin, _set_development, and _get_development helpers to chainladder.core.axis.
  • Deprecate odims (Deprecate odims #1012) and ddims (Deprecate ddims #1013) on Triangle with FutureWarning shims pointing to origin and development.
  • Update internal usage across core modules, estimators, adjustments, and tails to prevent internal deprecation warnings.
  • Preserve legacy pickle compatibility in Triangle.__setstate__ to migrate legacy pickled instances cleanly.
  • Add test coverage for 4-axis descriptor validation, edge cases, deprecation warnings, and pickle round-trips.

Related GitHub Issue(s)

Closes #1012, closes #1013, closes #1053 , #1454, refs #601, refs #1216, refs #1466

Additional Context for Reviewers

Checklist

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

Note

High Risk
This is a broad refactor of Triangle’s core axis model and touches arithmetic, slicing, pickle migration, and most estimators; regressions could surface as subtle misalignment of origin/development labels or broken legacy pickles.

Overview
This PR replaces direct odims/ddims usage with origin and development managed through TriangleAxis descriptors (axes 2 and 3), storing raw coordinates in Triangle._axes alongside index and columns. Getter/setter logic moves into chainladder.core.axis (_get_origin, _set_origin, _get_development, _set_development), with _set_axis / set_unchecked so slicing, arithmetic broadcasting, and concat can widen axes without length checks.

Triangle construction, valuation, dev_to_val/val_to_dev, grain, sort_axis, slicing, and I/O now read and write the new APIs; __setstate__ migrates legacy pickles that still carry odims/ddims (or kdims/vdims) into _axes. The development setter gains richer parsing (fractional lags, pattern labels, ultimate 9999, valuation-period fallback), and several estimators (bootstrap, incremental, tails, etc.) reject valuation triangles via is_val_tri instead of inspecting internal dtype.

Tests are expanded heavily for axis descriptors, edge cases, fractional ages, and pickle round-trips; call sites across core, development, methods, tails, and utils are updated to origin/development (or _axes[2]/_axes[3] where internal).

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

@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.26374% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.40%. Comparing base (687e329) to head (54e1614).

Files with missing lines Patch % Lines
chainladder/core/axis.py 91.95% 3 Missing and 11 partials ⚠️
chainladder/core/triangle.py 97.26% 2 Missing ⚠️
chainladder/core/pandas.py 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1304      +/-   ##
==========================================
+ Coverage   95.03%   95.40%   +0.37%     
==========================================
  Files         100      100              
  Lines        6471     6688     +217     
  Branches      819      874      +55     
==========================================
+ Hits         6150     6381     +231     
+ Misses        203      186      -17     
- Partials      118      121       +3     
Flag Coverage Δ
unittests 95.40% <96.26%> (+0.37%) ⬆️

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.

@github-actions

github-actions Bot commented Sep 5, 2026 •

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): 17.9% of exported symbols fully typed (305 / 1705)

Known Ambiguous Unknown Total
Project (head) 305 96 1304 1705

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: 337
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 7.4% fully typed (2 / 27); 2 no longer exported

Known Ambiguous Unknown Total
Patch 2 0 25 27
Patch symbol details
Symbol Status Change
chainladder.adjustments.tests.test_bootstrap.test_bootstrap_odp_val_triangle_error ❌ unknown new
chainladder.core.axis.TriangleAxis.set_unchecked ❌ unknown new
chainladder.core.tests.test_triangle.test_axis_descriptor_set_unchecked ❌ unknown new
chainladder.core.tests.test_triangle.test_centralized_axis_edge_cases ❌ unknown new
chainladder.core.tests.test_triangle.test_fractional_ages_predict_and_tails ❌ unknown new
chainladder.core.tests.test_triangle.test_set_axis ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_fractional_ages ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_fractional_pattern_round_trip ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_non_numeric_pattern_fallback ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_period_index_valuation_and_valuation_property ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_ultimate_token ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_valuation_string_labels ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_whole_floats_convert_to_int ❌ unknown new
chainladder.core.tests.test_triangle.test_set_development_year_strings_fallback_valuation ❌ unknown new
chainladder.core.tests.test_triangle.test_set_index_non_dataframe_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_set_origin_all_pattern ❌ unknown new
chainladder.core.tests.test_triangle.test_sort_axis_fractional_pattern ❌ unknown new
chainladder.core.triangle.Triangle.development ✅ known changed (was ❌ unknown)
chainladder.core.triangle.Triangle.origin ✅ known changed (was ❌ unknown)
chainladder.development.tests.test_constant.test_constant_dataframe_with_origin_development_columns ❌ unknown new
chainladder.development.tests.test_constant.test_constant_incr_cumulative_none ❌ unknown new
chainladder.development.tests.test_incremental.test_incremental_additive_val_triangle_error ❌ unknown new
chainladder.development.tests.test_munich.test_munich_properties ❌ unknown new
chainladder.methods.tests.test_predict.test_predict_age_exceeds_model ❌ unknown new
chainladder.tails.tests.test_clark.test_clark_g_list_of_ages ❌ unknown new
chainladder.tails.tests.test_constant.test_constant_attachment_age ❌ unknown new
chainladder.tails.tests.test_exponential.test_tail_curve_attachment_age ❌ unknown new
chainladder.core.triangle.Triangle.ddims — no longer exported (was ✅ known)
chainladder.core.triangle.Triangle.odims — no longer exported (was ✅ known)

@priyam0k
priyam0k changed the base branch from main to feature/deprecate-dims September 5, 2026 16:55
@priyam0k
priyam0k force-pushed the feature/deprecate-date-dims branch from 7bcf3d0 to 0c87d2e Compare September 5, 2026 20:10

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread chainladder/development/constant.py Resolved
@priyam0k
priyam0k force-pushed the feature/deprecate-date-dims branch from a9f5c57 to c6e0c8d Compare September 8, 2026 23:31
@priyam0k
priyam0k force-pushed the feature/deprecate-date-dims branch 4 times, most recently from 7d7efdc to 4253b6e Compare September 9, 2026 12:37
@priyam0k
priyam0k force-pushed the feature/deprecate-date-dims branch from 4253b6e to 8b192f3 Compare September 12, 2026 07:45

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread chainladder/core/triangle.py Resolved
@priyam0k
priyam0k marked this pull request as draft September 20, 2026 09:42
@priyam0k
priyam0k removed this pull request from stack #1305 September 29, 2026 21:58
@priyam0k
priyam0k changed the base branch from feature/deprecate-dims to feature/deprecate-kdims September 29, 2026 21:58
@priyam0k priyam0k changed the title Feature/deprecate date dims [FEAT]deprecate date dims Sep 29, 2026
@priyam0k
priyam0k added this pull request to stack #1437 September 29, 2026 21:59
@priyam0k
priyam0k marked this pull request as ready for review October 2, 2026 10:35
@priyam0k priyam0k mentioned this pull request Oct 2, 2026
3 of 11 tasks

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread chainladder/core/axis.py Resolved
@priyam0k

priyam0k commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

let me know if you're ready for me to take another look. GitHub just changed their PR interface to reverse the chronological order of the comments so I'm a little disoriented right now.

Noticed that here too. Switched back to the old preview using the sort toggle at the top of the timeline. The PR is rebased on main, conflict-free, and ready for another look.

can you take a look at it and see how far you can get without changing the public API?

Tested your branch against the suite. The 5 test failures come from dev_to_val returning Period objects instead of formatted string labels (like 2003Q4) and synthetic period_range under concat ignore_index.

Adopted the setter pattern from your sketch: added TriangleAxis.set_unchecked and check=False across _set_axis, _set_origin, and _set_development. Slicing (_LocBase, TriangleSlicer._slice) and dunders (_prep_origin_development) now route through axis descriptors rather than raw _axes mutations, without altering public return types. The test suite passes cleanly.

I created issues #1537 and #1538 which I think are main blockers for getting #601 done.

Making triangle.index an Index/MultiIndex (#1537) and development an Index (#1538), along with returning PeriodIndex from dev_to_val (#1536), are breaking changes that belong in 1.0.0.

PR #1304 completes the odims and ddims deprecation without breaking public contracts. Open to other ideas.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread chainladder/core/axis.py Resolved
Comment thread chainladder/core/triangle.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 fa0d1e1. Configure here.

Comment thread chainladder/core/axis.py Resolved
@priyam0k

Copy link
Copy Markdown
Contributor Author

@genedan this is ready for review, lot of back and forth here 😬

@henrydingliu

Copy link
Copy Markdown
Member

I'm doing a pre-thanksgiving clean-up.

@priyam0k @genedan how close are we from actually wrapping this up? do we need to start thinking about taking bite-sized chunks rather than sticking with this single PR approach?

@priyam0k

Copy link
Copy Markdown
Contributor Author

Just cleared the conflicts with main and pushed. We kept this strictly to wrapping up the odims/ddims deprecation and left the bigger Index refactor for 1.0. Getting this in now should prevent the recurring merge conflicts whenever other PRs land on main, but open to splitting it into bite-sized PRs if preferred.

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.

[DISCUSSION] Create centralized axis mapping Deprecate ddims Deprecate odims

3 participants