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

Add a hypothesis test for __getitem__ #1098

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sjdenny
Copy link

@sjdenny sjdenny commented Sep 30, 2024

Compares polars __getitem__ calls with pandas & pyarrow.

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below.

Putting this up for initial feedback - there's a bunch of cases which pyarrow doesn't support (documented in the test). Do we want to support these cases, or should be instead tighten the test (on pandas as well) and declare these unsupported for now?

Cases:

  • pyarrow: doesn't support negative indexes
  • pyarrow: pairs of slices unsupported, e.g. df[0:1, 'a':'b'] (trivial pairs such as df[:, 'a':'b'] where one slice is : are an exception).
  • pyarrow: empty edge case, e.g. df[[], "a":] fails.
  • pyarrow & pandas: df[..., ::step] is unsupported, ie slice(None, None, <something>)

@sjdenny sjdenny marked this pull request as ready for review September 30, 2024 11:05
Compares polars with pandas & pyarrow.
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

this is awesome, thanks @sjdenny !

looks like there's a failure in the "random versions" CI job (specifically, pandas==2.0.3)

if we can address that, then I think we can merge this can then gradually address the rest

@sjdenny
Copy link
Author

sjdenny commented Oct 2, 2024

Thanks @MarcoGorelli !

looks like there's a failure in the "random versions" CI job (specifically, pandas==2.0.3)

Looks like this was a flake instead (at least, I was able to reproduce on pandas==2.2.3 too, by running through more examples). I've bumped the number of samples up to 10k in db69469: this does (did) reliably find the failing case, but the downside is it's a bit of a slow test now. Which end of the tradeoff scale do you want to go for? Related to this, I saw Hypothesis has settings profiles, which look neat for supporting faster settings locally & more thorough sampling in CI.

@sjdenny
Copy link
Author

sjdenny commented Oct 3, 2024

Ah, coverage now. Looking πŸ‘€

@MarcoGorelli
Copy link
Member

awesome stuff, thanks!

there's a couple of really minor things i wanted to address, but i'll try to get this in shortly, really appreciate your contribution here πŸ™

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: add hypothesis test for DataFrame.__getitem__
2 participants