Skip to content

refactor(core): extract duplicate drop validation to _validate_contig… - #1286

Merged
genedan merged 2 commits into
casact:mainfrom
priyam0k:refactor/issue-1267-drop-duplicate
Sep 5, 2026
Merged

refactor(core): extract duplicate drop validation to _validate_contig…#1286
genedan merged 2 commits into
casact:mainfrom
priyam0k:refactor/issue-1267-drop-duplicate

Conversation

@priyam0k

@priyam0k priyam0k commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Extracted duplicate contiguous drop validation in TrianglePandas.drop() into private helper _validate_contiguous_drop(). Added unit test coverage for the helper.

Related GitHub Issue(s)

Closes #1267

Additional Context for Reviewers

Pure refactoring that preserves all existing behavior, exception types, and error messages.

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

Low Risk
Behavior-preserving refactor of Triangle.drop() validation with added unit tests; no API or logic changes beyond deduplication.

Overview
Pulls the shared origin and development drop rules out of TrianglePandas.drop() into a static helper _validate_contiguous_drop, which checks missing labels (KeyError / errors='ignore'), enforces edge-only contiguous drops (ValueError on interior gaps), and returns the boolean keep mask. drop() on those axes now delegates to the helper; behavior and messages stay the same.

Adds test_validate_contiguous_drop_helper to exercise the helper directly (valid first/last drops, missing labels, interior drop). The rest of the diff is mostly formatting in pandas.py and test style tweaks.

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

@github-actions

github-actions Bot commented Sep 4, 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): 15.4% of exported symbols fully typed (213 / 1382)

Known Ambiguous Unknown Total
Project (head) 213 111 1058 1382

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

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

Known Ambiguous Unknown Total
Patch 0 0 1 1
Patch symbol details
Symbol Status Change
chainladder.core.tests.test_triangle.test_validate_contiguous_drop_helper ❌ unknown new

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.67%. Comparing base (670e86a) to head (eb84f3a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1286      +/-   ##
==========================================
- Coverage   91.68%   91.67%   -0.01%     
==========================================
  Files          93       93              
  Lines        5447     5443       -4     
  Branches      704      702       -2     
==========================================
- Hits         4994     4990       -4     
  Misses        328      328              
  Partials      125      125              
Flag Coverage Δ
unittests 91.67% <100.00%> (-0.01%) ⬇️

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

looks good! do the ruff fixes allow any deletion of per-file ignore in pyproject.toml?

@priyam0k

priyam0k commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

No, neither pandas.py nor test_triangle.py had entries in per-file-ignores. The commit only applied ruff format to satisfy the CI format check on the touched files.

@genedan
genedan merged commit 5df817f into casact:main Sep 5, 2026
13 checks passed
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.

Duplicate code fragment in TrianglePandas.drop()

3 participants