Skip to content

Commit

Permalink
fix nested min max (#2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 25, 2022
1 parent 0a8ede9 commit ebcc035
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions polars/polars-lazy/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ fn max_exprs_impl(mut exprs: Vec<Expr>) -> Expr {
.map_many(
|s| {
let s = s.to_vec();
let df = DataFrame::new(s)?;
let df = DataFrame::new_no_checks(s);
df.hmax().map(|s| s.unwrap())
},
&exprs[1..],
Expand All @@ -618,7 +618,7 @@ fn min_exprs_impl(mut exprs: Vec<Expr>) -> Expr {
.map_many(
|s| {
let s = s.to_vec();
let df = DataFrame::new(s)?;
let df = DataFrame::new_no_checks(s);
df.hmin().map(|s| s.unwrap())
},
&exprs[1..],
Expand Down
7 changes: 7 additions & 0 deletions py-polars/tests/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,3 +1132,10 @@ def test_lower_bound_upper_bound(fruits_cars: pl.DataFrame) -> None:
assert res_expr["A"][0] < -10_000_000
res_expr = fruits_cars.select(pl.col("A").upper_bound())
assert res_expr["A"][0] > 10_000_000


def test_nested_min_max() -> None:
df = pl.DataFrame({"a": [1], "b": [2], "c": [3], "d": [4]})
out = df.with_column(pl.max([pl.min(["a", "b"]), pl.min(["c", "d"])]).alias("t"))
assert out.shape == (1, 5)
assert out["t"][0] == 3

0 comments on commit ebcc035

Please sign in to comment.