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

refactor: Fix flaky test #20751

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions crates/polars-expr/src/expressions/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,10 @@ impl ApplyExpr {
fn all_unit_length(ca: &ListChunked) -> bool {
assert_eq!(ca.chunks().len(), 1);

// Handles the Null dtype - in that case the offsets can be (e.g. [0,0,0 ...])
if ca.null_count() == ca.len() {
return true;
}

let list_arr = ca.downcast_iter().next().unwrap();
let offset = list_arr.offsets().as_slice();
(offset[offset.len() - 1] as usize) == list_arr.len()
// Note: Checking offset.last() == 0 handles the Null dtype - in that case the offsets can be (e.g. [0,0,0 ...])
(offset[offset.len() - 1] as usize) == list_arr.len() || offset[offset.len() - 1] == 0
}

fn check_map_output_len(input_len: usize, output_len: usize, expr: &Expr) -> PolarsResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/map/test_map_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ def foo(x: pl.Series) -> pl.Series:
pl.DataFrame({"key": [0, 0, 1], "a": [None, None, None]})
.group_by("key")
.agg(pl.map_groups(exprs=["a"], function=foo)) # type: ignore[arg-type]
.sort("a"),
.sort("key"),
pl.DataFrame({"key": [0, 1], "a": [None, None]}),
)
Loading