Skip to content

feat(core): allow Triangle.drop() development dropping, label validation, and error options - #1207

Open
priyam0k wants to merge 5 commits into
mainfrom
feature/drop-development
Open

feat(core): allow Triangle.drop() development dropping, label validation, and error options#1207
priyam0k wants to merge 5 commits into
mainfrom
feature/drop-development

Conversation

@priyam0k

@priyam0k priyam0k commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

completes Triangle.drop() functionality for #1052:

  • drop development periods via development=, axis=3, or axis='development'. requires dropping first/last periods to prevent gaps.
  • validates labels=None. raises ValueError if no labels or axis keywords are passed.
  • adds level and errors parameters (errors='ignore' suppresses missing label KeyErrors).

Related GitHub Issue(s)

closes #1057 #1062 #1061
part of #1052

Additional Context for Reviewers

#1051 (index label dropping) remains

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

Medium Risk
Changes core Triangle slicing/validation behavior; wrong edge cases could alter triangle shape, but rules mirror existing origin drops and are heavily tested.

Overview
Triangle.drop() now supports dropping development periods via development=, axis=3, or axis='development', using the same first/last-only rule as origin (interior drops raise ValueError). Missing labels on columns, origin, and development honor a new errors argument ('raise' vs 'ignore'); level is documented for API parity. Calling drop() with no labels/axis keywords now raises ValueError, and column drops check for missing names before slicing.

Docs gain a development-drop doctest; NotImplementedError text now lists column, origin, and development (index still unimplemented).

Minor cleanups: isinstance instead of type() == in hvplot and tests; remove an unused xp in groupby aggregation; test/style fixes (is_cumulative booleans, expanded drop coverage).

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

@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): 15.0% of exported symbols fully typed (201 / 1336)

Known Ambiguous Unknown Total
Project (head) 201 111 1024 1336

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

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

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

Known Ambiguous Unknown Total
Patch 0 0 9 9
Patch symbol details
Symbol Status Change
chainladder.core.tests.test_triangle.test_drop_both_labels_and_alternative_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_development_axis_equivalents ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_development_first ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_development_interior_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_development_last ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_development_missing_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_errors_ignore ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_index_alternative_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_no_labels_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_index_origin_development_alternatives_raise no longer exported (was ❌ unknown)

@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 23030c6. Configure here.

"Only the first or last development periods may be dropped; "
"dropping an interior development period would leave a gap."
)
result = result._slice(keep, "ddims")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Development drop skips valuation date

Medium Severity

Development drop() slices ddims through _slice and never refreshes valuation_date. On a valuation triangle, removing the latest period leaves valuation_date on a removed calendar date, so latest_diagonal and other valuation-date checks no longer match remaining cells.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 23030c6. Configure here.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.46%. Comparing base (26a4a5c) to head (23030c6).
⚠️ Report is 317 commits behind head on main.

Files with missing lines Patch % Lines
chainladder/core/pandas.py 85.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1207      +/-   ##
==========================================
+ Coverage   91.25%   91.46%   +0.21%     
==========================================
  Files          91       91              
  Lines        5395     5577     +182     
  Branches      689      743      +54     
==========================================
+ Hits         4923     5101     +178     
- Misses        338      339       +1     
- Partials      134      137       +3     
Flag Coverage Δ
unittests 91.46% <85.00%> (+0.21%) ⬆️

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.

@henrydingliu

Copy link
Copy Markdown
Member

these reviews are gonna be challenging, with the mix of ruff debugging and actual code change.

@genedan would love to get your take

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.

Allow Triangle.drop() to drop development periods

2 participants