8000 feat: add `Table.delete_row` method by tlambert03 · Pull Request #610 · pyapp-kit/magicgui · GitHub
[go: up one dir, main page]

Skip to content

feat: add Table.delete_row method#610

Merged
tlambert03 merged 2 commits intopyapp-kit:mainfrom
tlambert03:row-del
Oct 30, 2023
Merged

feat: add Table.delete_row method#610
tlambert03 merged 2 commits intopyapp-kit:mainfrom
tlambert03:row-del

Conversation

@tlambert03
Copy link
Member

cc @jni

would appreciate your input on the API. I considered using Table.drop like the pandas API, but I thought it might be confusing that this one is in-place and that one is not. I'm also wary of the confusion between row indices and row headers (both of which could conceivably be integers), so I forced the usage of a kwarg.

@codecov
Copy link
codecov bot commented Oct 29, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please 8000 review.

Comparison is base (aa38630) 87.75% compared to head (6f41ae5) 87.73%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
- Coverage   87.75%   87.73%   -0.02%     
==========================================
  Files          40       40              
  Lines        4705     4722      +17     
==========================================
+ Hits         4129     4143      +14     
- Misses        576      579       +3     
Files Coverage Δ
src/magicgui/widgets/_table.py 95.56% <82.35%> (-0.58%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

else:
indices.add(index)
if header is not None:
if isinstance(header, str) or not isinstance(header, Sequence):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, I needed a double-take to understand why this wasn't just not isinstance(header, Sequence). That's annoying 😂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, classic :) string is a sequence but not "that" kind :)

@jni
Copy link
Contributor
jni commented Oct 30, 2023

Missing a couple of test coverage lines, but looks good to me. I basically agree with your assessment. I wouldn't look to the pandas API but the draft DataFrame API, which bizarrely has drop_columns but not drop_rows — perhaps they are leaking implementation details into their API choices? 😂 I also couldn't find an issue in their repo. But anyway, drop_columns appears to be in-place (returns Self), so maybe drop_rows would be a good analogous method name? And maybe we should make an issue in their repo, though I don't feel super strongly about it.

@tlambert03
Copy link
Member Author
tlambert03 commented Oct 30, 2023

Thanks!

Btw: I would not assume that it's in place because of -> Self. That means it returns "type of self" (not actual self)

See this type of usage for example: https://peps.python.org/pep-0673/#use-in-classmethod-signatures

@tlambert03 tlambert03 merged commit 0386cbb into pyapp-kit:main Oct 30, 2023
@tlambert03 tlambert03 deleted the row-del branch October 30, 2023 13:15
@jni
Copy link
Contributor
jni commented Oct 30, 2023

Fascinating! Thanks for the info!

@tlambert03 tlambert03 added the enhancement New feature or request label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0