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(rust): Reject non-integral offset and length in AExpr::Slice #16874

Merged
merged 3 commits into from
Jun 13, 2024

Conversation

wence-
Copy link
Collaborator

@wence- wence- commented Jun 11, 2024

@github-actions github-actions bot added fix Bug fix rust Related to Rust Polars labels Jun 11, 2024
Copy link

codspeed-hq bot commented Jun 11, 2024

CodSpeed Performance Report

Merging #16874 will not alter performance

Comparing wence-:wence/fix/16855 (cbe4091) with main (e29d28e)

Summary

✅ 37 untouched benchmarks

@wence- wence- force-pushed the wence/fix/16855 branch from c16c884 to c2a4f41 Compare June 11, 2024 10:51
Copy link
Collaborator Author

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Signposts

py-polars/tests/unit/dataframe/test_df.py Show resolved Hide resolved
py-polars/tests/unit/expr/test_exprs.py Show resolved Hide resolved
Comment on lines 4854 to 4858
# This cast enables tail with expressions that return unsigned integers,
# for which negate otherwise raises InvalidOperationError.
offset = -self._from_pyexpr(
parse_as_expression(n).cast(Int64, strict=False, wrap_numerical=True)
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is arguably a "feature" improvement. Previously one could not ask for the tail for an expression with an expression value of unsigned integer type. That is, this enables the following:

df.select(pl.col("a").tail(pl.lit(1, pl.UInt32()))

The casting is similar to the rust side implementation of tail:

    /// Get the last `n` elements of the Expr result.
    pub fn tail(self, length: Option<usize>) -> Self {
        let len = length.unwrap_or(10);
        self.slice(lit(-(len as i64)), lit(len as u64))
    }

@wence- wence- force-pushed the wence/fix/16855 branch from 083f2d9 to 93fbb0e Compare June 11, 2024 11:18
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.09%. Comparing base (8965a68) to head (cbe4091).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16874      +/-   ##
==========================================
- Coverage   81.10%   81.09%   -0.02%     
==========================================
  Files        1435     1435              
  Lines      189546   189555       +9     
  Branches     2712     2712              
==========================================
- Hits       153732   153719      -13     
- Misses      35314    35336      +22     
  Partials      500      500              

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

@wence- wence- force-pushed the wence/fix/16855 branch from 93fbb0e to 5618d4c Compare June 12, 2024 09:25
@ritchie46
Copy link
Member

Ah.. Sorry for the inconvenience, but can you rebase? Seems to be some conflicts.

@wence- wence- force-pushed the wence/fix/16855 branch from 5618d4c to cbe4091 Compare June 13, 2024 10:06
@wence-
Copy link
Collaborator Author

wence- commented Jun 13, 2024

Ah.. Sorry for the inconvenience, but can you rebase? Seems to be some conflicts.

Done.

@ritchie46 ritchie46 merged commit 9914d96 into pola-rs:main Jun 13, 2024
27 checks passed
@wence- wence- deleted the wence/fix/16855 branch June 13, 2024 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[QST]: should pl.Expr.slice raise if the numeric arguments are not integral
2 participants