Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Table.delete_row method #610

Merged
merged 2 commits into from
Oct 30, 2023
Merged

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 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
34 checks passed
@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.

None yet

2 participants