Add index, columns, origin, development alternatives to Triangle.drop()#1131
Add index, columns, origin, development alternatives to Triangle.drop()#1131priyam0k wants to merge 5 commits into
Conversation
…ngle.drop() Route the keyword alternatives to their axis, mirroring pandas. Refs casact#1060.
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): 0.0% fully typed (0 / 6)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1131 +/- ##
==========================================
+ Coverage 90.81% 90.82% +0.01%
==========================================
Files 91 91
Lines 5300 5308 +8
Branches 673 676 +3
==========================================
+ Hits 4813 4821 +8
Misses 346 346
Partials 141 141
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:
|
|
@genedan wanna take this one? |
|
Okay, I'm gonna help knock out the contributing guide draft beforehand. Might take me a day or two? I figured I need to get on it since we keep talking about it. |
genedan
left a comment
There was a problem hiding this comment.
Finally got around to this, many thanks for the PR. I only have minor comments.
Address review on casact#1131: format the long drop() signature one arg per line and add testable Examples to the docstring.
Normalize any scalar (str or int) into a list so a bare int routes to its axis instead of raising TypeError. Addresses Bugbot review on casact#1131.
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.
Reviewed by Cursor Bugbot for commit 2a7c50e. Configure here.
Use np.isscalar so pd.Index/ndarray labels pass through list() while scalars (str/int) are wrapped, and a bare drop() still raises. Addresses Bugbot review on casact#1131.
Print the triangle's original columns before the drop, per review on casact#1131.

Summary of Changes
Adds
index,columns,origin, anddevelopmentkeyword alternatives toTriangle.drop(), mirroringDataFrame.drop().columns=...equalslabels=..., axis=1,index=...equalsaxis=0, and so onlabelstogether with any alternative raisesValueError, matching pandascolumns=works today since the column axis is implemented;index,origin, anddevelopmentroute to their axis and still raiseNotImplementedErroruntil those axes land in Allow TrianglePandas.drop() to drop index labels #1051, Allow Triangle.drop() to drop origin levels #1055, Allow Triangle.drop() to drop development periods #1057Related GitHub Issue(s)
closes #1060, part of #1052
Additional Context for Reviewers
kept the
labels=Nonewith nothing specified path as is, that is handled separately in [BUG] Handle case when labels=None in Triangle.drop() #1062no behavior change for the existing
labels/axisformI passed tests locally for code (
pytest)Note
Low Risk
API extension with preserved behavior for labels/axis; column drops use existing selection logic and are covered by new tests.
Overview
Triangle.drop()now acceptsindex,columns,origin, anddevelopmentas alternatives tolabels+axis, aligned withDataFrame.drop(). For example,drop(columns='CumPaidLoss')matchesdrop(labels='CumPaidLoss', axis=1). Mixinglabelswith any of those kwargs raisesValueError.Implementation builds a per-axis drop map, normalizes scalars with
np.isscalar(so integer development labels do not hit the oldtype(labels) is strbug), and can apply multiple axis kwargs in one call. Only the column axis still performs drops;index,origin, anddevelopmentroute to their axes and raiseNotImplementedErroruntil follow-up work lands. Thelabels/axisAPI is unchanged.TriangleProtocoland docs/examples were updated; tests cover equivalence, lists, conflicts, unimplemented axes, and list-likecolumnsinputs.Reviewed by Cursor Bugbot for commit 65f70d0. Bugbot is set up for automated code reviews on this repo. Configure here.