Add index, columns, origin, development alternatives to Triangle.drop()#1131
Add index, columns, origin, development alternatives to Triangle.drop()#1131priyam0k wants to merge 4 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.
| .. testcode:: | ||
|
|
||
| tri = cl.load_sample('clrd') | ||
| print(tri.drop(columns='CumPaidLoss').columns.tolist()) |
There was a problem hiding this comment.
I would recommend adding 1 more print statement showing the original columns of the triangle.

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
Column-drop behavior for the legacy API is preserved; new kwargs mainly add routing and errors on non-column axes, with coverage in unit tests.
Overview
Triangle.drop()now acceptsindex,columns,origin, anddevelopmentas pandas-style shortcuts (e.g.tri.drop(columns='CumPaidLoss')instead oflabels=..., axis=1). Mixinglabelswith any of those kwargs raisesValueError.Implementation builds a per-axis drop map and normalizes scalars with
np.isscalar; only the column axis still drops data—other axes route through the same path and raiseNotImplementedErroruntil follow-up work lands. The existinglabels/axisAPI is unchanged.TriangleProtocoland doctest examples were updated; tests cover equivalence, list/index-likecolumns, conflicts, and unimplemented axes.Reviewed by Cursor Bugbot for commit 8157830. Bugbot is set up for automated code reviews on this repo. Configure here.