From f5261064c7ff4b62269749a3c3207be2fdce3ca8 Mon Sep 17 00:00:00 2001 From: Weijie Guo Date: Sat, 20 Jan 2024 00:29:09 +0800 Subject: [PATCH] fix(rust): Correct err message of `check_map_output_len` --- crates/polars-lazy/src/physical_plan/expressions/apply.rs | 2 +- py-polars/tests/unit/operations/map/test_map_batches.py | 8 ++++---- py-polars/tests/unit/test_errors.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/polars-lazy/src/physical_plan/expressions/apply.rs b/crates/polars-lazy/src/physical_plan/expressions/apply.rs index 6746cd0c0272..ea664b4dafcd 100644 --- a/crates/polars-lazy/src/physical_plan/expressions/apply.rs +++ b/crates/polars-lazy/src/physical_plan/expressions/apply.rs @@ -285,7 +285,7 @@ fn check_map_output_len(input_len: usize, output_len: usize, expr: &Expr) -> Pol polars_ensure!( input_len == output_len, expr = expr, InvalidOperation: "output length of `map` ({}) must be equal to the input length ({}); \ - consider using `apply` instead", input_len, output_len + consider using `apply` instead", output_len, input_len ); Ok(()) } diff --git a/py-polars/tests/unit/operations/map/test_map_batches.py b/py-polars/tests/unit/operations/map/test_map_batches.py index 1a2826f319c4..2cde056cc652 100644 --- a/py-polars/tests/unit/operations/map/test_map_batches.py +++ b/py-polars/tests/unit/operations/map/test_map_batches.py @@ -36,8 +36,8 @@ def test_error_on_reducing_map() -> None: with pytest.raises( pl.InvalidOperationError, match=( - r"output length of `map` \(6\) must be equal to " - r"the input length \(1\); consider using `apply` instead" + r"output length of `map` \(1\) must be equal to " + r"the input length \(6\); consider using `apply` instead" ), ): df.group_by("id").agg(pl.map_batches(["t", "y"], np.trapz)) @@ -47,8 +47,8 @@ def test_error_on_reducing_map() -> None: with pytest.raises( pl.InvalidOperationError, match=( - r"output length of `map` \(4\) must be equal to " - r"the input length \(1\); consider using `apply` instead" + r"output length of `map` \(1\) must be equal to " + r"the input length \(4\); consider using `apply` instead" ), ): df.select( diff --git a/py-polars/tests/unit/test_errors.py b/py-polars/tests/unit/test_errors.py index dda6fe590737..f6b5b2df8110 100644 --- a/py-polars/tests/unit/test_errors.py +++ b/py-polars/tests/unit/test_errors.py @@ -30,8 +30,8 @@ def test_error_on_reducing_map() -> None: with pytest.raises( pl.InvalidOperationError, match=( - r"output length of `map` \(6\) must be equal to " - r"the input length \(1\); consider using `apply` instead" + r"output length of `map` \(1\) must be equal to " + r"the input length \(6\); consider using `apply` instead" ), ): df.group_by("id").agg(pl.map_batches(["t", "y"], np.trapz)) @@ -40,8 +40,8 @@ def test_error_on_reducing_map() -> None: with pytest.raises( pl.InvalidOperationError, match=( - r"output length of `map` \(4\) must be equal to " - r"the input length \(1\); consider using `apply` instead" + r"output length of `map` \(1\) must be equal to " + r"the input length \(4\); consider using `apply` instead" ), ): df.select(