Skip to content

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

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

feat(core): allow Triangle.drop() development dropping, label validation, and error options#1207
priyam0k wants to merge 19 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 Add parameters to Triangle.drop() #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).
  • Resolved all Ruff lint violations in pandas.py and test_triangle.py and removed both files from ignore in pyproject.toml (part of Initial Linting Cleanup #1216).

Related GitHub Issue(s)

closes #1057 #1062 #1061
part of #1052
part of #1216

Additional Context for Reviewers

  • Allow TrianglePandas.drop() to drop index labels #1051 (index label dropping) remains
  • all core logic changes for Triangle.drop() are in chainladder/core/pandas.py (and the new drop unit tests in test_triangle.py).
  • the extra ruff edits in pandas.py (2 minor lints) and test_triangle.py (legacy boolean equality lints) were required for pre-commit CI to pass. all bugbot findings are also fully resolved.

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/drop semantics on origin and development axes and valuation metadata; behavior is well covered by new tests but affects user-facing data shape logic.

Overview
Triangle.drop() now supports dropping development periods via development=, axis=3, or axis='development', with the same first/last-only rule as origin (interior drops raise ValueError). Missing labels honor a new errors parameter ('raise' vs 'ignore'); level is accepted for API parity but only allowed with the index axis (still unimplemented).

Input validation is tighter: calling drop() with no labels/axis keywords raises ValueError, and columns/origin/development missing-label checks respect errors. After development drops on valuation triangles, valuation_date is updated; dropping the ultimate dev period clears is_ultimate. Origin-drop dev trimming after NaN columns now uses NumPy dense paths instead of the backend array module.

Docs/examples cover development dropping; hvplot uses isinstance for PeriodIndex. Ruff cleanups in pandas.py and test_triangle.py plus removal of those files from pyproject.toml per-file ignores; extensive new unit tests cover drop behavior.

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

@github-actions

github-actions Bot commented Aug 13, 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): 14.9% of exported symbols fully typed (202 / 1355)

Known Ambiguous Unknown Total
Project (head) 202 111 1042 1355

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

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

Known Ambiguous Unknown Total
Patch 0 0 20 20
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_both_labels_and_axis_keyword_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_development_updates_valuation_date ❌ 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_index_axis_not_implemented_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_interior_development_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_interior_origin_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_invalid_errors_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_level_non_index_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_no_arguments_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_no_labels_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_ultimate_column_updates_is_ultimate ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_unsupported_axis_raises ❌ unknown new
chainladder.core.tests.test_triangle.test_hvplot_passthrough ❌ unknown new
chainladder.core.tests.test_triangle.test_drop_index_origin_development_alternatives_raise no longer exported (was ❌ unknown)

Comment thread chainladder/core/pandas.py
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.31%. Comparing base (606be5c) to head (8d05187).

Files with missing lines Patch % Lines
chainladder/core/pandas.py 90.32% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1207      +/-   ##
==========================================
+ Coverage   91.27%   91.31%   +0.03%     
==========================================
  Files          91       91              
  Lines        5411     5434      +23     
  Branches      692      700       +8     
==========================================
+ Hits         4939     4962      +23     
+ Misses        338      336       -2     
- Partials      134      136       +2     
Flag Coverage Δ
unittests 91.31% <90.32%> (+0.03%) ⬆️

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

Comment thread chainladder/core/pandas.py
@priyam0k

priyam0k commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

all core logic changes for Triangle.drop() are in chainladder/core/pandas.py (and the new drop unit tests in test_triangle.py).

the extra ruff edits in pandas.py (2 minor lints) and test_triangle.py (legacy boolean equality lints) were required for pre-commit CI to pass. all bugbot findings are also fully resolved.

@henrydingliu

Copy link
Copy Markdown
Member

need to cover one more line to meet patch coverage

Comment thread chainladder/core/tests/test_triangle.py
@priyam0k
priyam0k force-pushed the feature/drop-development branch from 2de8840 to 8410299 Compare August 15, 2026 03:52
@henrydingliu

Copy link
Copy Markdown
Member

friendly reminder to edit pyproject after you fix the ruff violations

@priyam0k

priyam0k commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

thanks removed per-file-ignores in pyproject.toml , (part of #1216)

@priyam0k
priyam0k force-pushed the feature/drop-development branch from a410909 to 0b87279 Compare August 15, 2026 04:50

@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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0b87279. Configure here.

Comment thread chainladder/core/pandas.py
@priyam0k

priyam0k commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

@henrydingliu all CI checks and tests are passing. updated pyproject.toml as requested.
codecov patch runs early before all test matrix runners finish uploading, can open an issue to fix codecov.yml if needed. ready for review!

@henrydingliu

Copy link
Copy Markdown
Member

looking at the time stamps, codecov patch starts after unittest is done. the same new lines for checking missing columns show as uncovered in both patch and project. in any case, 90% diff hit is sufficient for merging. i can approve once conflict is resolved.

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