-
Notifications
You must be signed in to change notification settings - Fork 915
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 test coverage for slicing with "out of bounds" negative indices #15990
Add test coverage for slicing with "out of bounds" negative indices #15990
Conversation
Sometimes we might want to avoid running certain optimization passes, so enable that in the testing assertion function.
Polars wraps negative starts and then clamps both the resulting start and length to [0, num_rows), so we should do that. Add tests of this behaviour as well.
Before:
After:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One naming request, otherwise LGTM.
) | ||
def test_slice(offset, len): | ||
@pytest.mark.parametrize("slice_pushdown", [False, True]) | ||
def test_slice(offset, len, slice_pushdown): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid shadowing the Python built-in len
. I would rename this parameter to length
to match the Polars API: https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.slice.html
/merge |
Description
Polars wraps negative starts and then clamps both the resulting start
and length to [0, num_rows), so we should do that.
Add tests of this behaviour as well.
Checklist