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 test coverage for slicing with "out of bounds" negative indices #15990

Merged
merged 3 commits into from
Jun 12, 2024

Conversation

wence-
Copy link
Contributor

@wence- wence- commented Jun 12, 2024

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

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

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.
@wence- wence- requested a review from a team as a code owner June 12, 2024 11:46
@github-actions github-actions bot added Python Affects Python cuDF API. cudf.polars Issues specific to cudf.polars labels Jun 12, 2024
@wence-
Copy link
Contributor Author

wence- commented Jun 12, 2024

Before:

---------- coverage: platform linux, python 3.10.14-final-0 ----------
Name                                  Stmts   Miss  Cover
---------------------------------------------------------
TOTAL                                  1322    249    81%

After:

--------- coverage: platform linux, python 3.10.14-final-0 ----------
Name                                  Stmts   Miss  Cover
---------------------------------------------------------
TOTAL                                  1328    247    81%

@wence- wence- added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jun 12, 2024
Copy link
Contributor

@bdice bdice left a 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):
Copy link
Contributor

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

@wence-
Copy link
Contributor Author

wence- commented Jun 12, 2024

/merge

@rapids-bot rapids-bot bot merged commit 9fae8ab into rapidsai:branch-24.08 Jun 12, 2024
74 checks passed
@wence- wence- deleted the wence/fea/coverage-slice branch June 12, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cudf.polars Issues specific to cudf.polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants