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

fix: Fix slice length no longer allowing None #17372

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

sherlockbeard
Copy link
Contributor

@sherlockbeard sherlockbeard commented Jul 2, 2024

Fixes #17365

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.74%. Comparing base (663fe4c) to head (4774381).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17372      +/-   ##
==========================================
+ Coverage   80.72%   80.74%   +0.02%     
==========================================
  Files        1475     1475              
  Lines      193383   193383              
  Branches     2760     2760              
==========================================
+ Hits       156113   156154      +41     
+ Misses      36760    36719      -41     
  Partials      510      510              

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

Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Looks correct to me.

@stinodego stinodego changed the title fixes(rust): slice length deafult None fix: Fix slice length no longer allowing None Jul 2, 2024
@stinodego stinodego changed the title fix: Fix slice length no longer allowing None fix: Fix slice length no longer allowing None Jul 2, 2024
@github-actions github-actions bot added python Related to Python Polars rust Related to Rust Polars labels Jul 2, 2024
@@ -451,7 +451,7 @@ impl OptimizationRule for TypeCoercionRule {
polars_ensure!(offset_dtype.is_integer(), InvalidOperation: "offset must be integral for slice, not {}", offset_dtype);
let (_, length_dtype) =
unpack!(get_aexpr_and_type(expr_arena, length, &input_schema));
polars_ensure!(length_dtype.is_integer(), InvalidOperation: "length must be integral for slice, not {}", length_dtype);
polars_ensure!(length_dtype.is_integer() || length_dtype.is_null(), InvalidOperation: "length must be integral for slice, not {}", length_dtype);
Copy link
Member

Choose a reason for hiding this comment

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

I think you should negate the check. !is_null.

@@ -747,3 +747,16 @@ def test_slice_rejects_non_integral() -> None:

with pytest.raises(pl.exceptions.InvalidOperationError):
df.select(pl.col("a").slice(pl.lit("1"), None)).collect()


def test_slice() -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Can you test what you want fixed? E.g. ensure that we raise on the invalid input.

@ritchie46
Copy link
Member

Ah, nevermind. I now see the issue. We want None.

@ritchie46 ritchie46 merged commit b81f6fa into pola-rs:main Jul 3, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expr.slice no longer allows length = None
3 participants