Allow Triangle.drop() to drop origin levels - #1163
Conversation
Implement origin-axis dropping (axis=2 / origin=). Only the first or last origin period(s) may be dropped so the triangle stays contiguous; interior drops raise ValueError and unknown labels raise KeyError. Closes casact#1055.
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): 14.3% fully typed (1 / 7)
Patch symbol details
|
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.
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 82fb260. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1163 +/- ##
==========================================
+ Coverage 90.94% 90.97% +0.02%
==========================================
Files 91 91
Lines 5325 5339 +14
Branches 675 678 +3
==========================================
+ Hits 4843 4857 +14
Misses 344 344
Partials 138 138
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Use pd.api.types.is_list_like instead of np.isscalar so a pd.Period (the origin axis native label type, e.g. tri.origin[-1]) is treated as a scalar rather than crashing on list(). None still flows through list() to preserve bare drop() behavior. Addresses Bugbot review on casact#1163.

Summary of Changes
Implements origin-level dropping in
Triangle.drop(), so origin periods can be removed viaorigin=oraxis=2/axis='origin', building on the axis routing added in #1131.tri.drop(origin='1990')andtri.drop(labels='1990', axis=2)are equivalentodimsandvaluesstay in syncValueErrorKeyErrordrop()docstringRelated GitHub Issue(s)
closes #1055, part of #1052
Additional Context for Reviewers
the origin /
axis=2path introduced in Add index, columns, origin, development alternatives to Triangle.drop() #1131 previously raisedNotImplementedError; this PR implements it. The corresponding test was updated to only assertNotImplementedErrorfor the still-unimplemented index and development axesthe "first or last only" rule is enforced by checking that the kept origin positions remain contiguous, which rejects interior drops that would leave a gap
development-axis dropping (Allow Triangle.drop() to drop development periods #1057) is intended as a follow-up using the same approach
I passed tests locally for code (
pytest)Note
Low Risk
Localized API extension in Triangle.drop() with explicit validation and thorough tests; no auth, persistence, or broad behavioral changes outside origin slicing.
Overview
Triangle.drop()now supports removing origin periods viaorigin=oraxis=2/axis='origin', alongside the existing column axis. Dropping uses boolean origin slicing soodimsand values stay aligned.Only first or last origin label(s) can be removed; interior drops that would leave a gap raise
ValueError. Missing labels raiseKeyError. Label handling is broadened withpd.api.types.is_list_like(including nativepd.Periodlabels).Docs add an origin-drop doctest; tests cover first/last drop, axis equivalents, interior guard, and missing labels. Index and development axes still raise
NotImplementedError.Reviewed by Cursor Bugbot for commit 82eb1a9. Bugbot is set up for automated code reviews on this repo. Configure here.