Skip to content

Commit e4ead38

Browse files
authored
fix: Mark Expr.repeat_by as elementwise (#22068)
1 parent 2feca5a commit e4ead38

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

Diff for: crates/polars-ops/src/chunked_array/repeat_by.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type LargeListArray = ListArray<i64>;
1111
fn check_lengths(length_srs: usize, length_by: usize) -> PolarsResult<()> {
1212
polars_ensure!(
1313
(length_srs == length_by) | (length_by == 1) | (length_srs == 1),
14-
ComputeError: "repeat_by argument and the Series should have equal length, or at least one of them should have length 1. Series length {}, by length {}",
14+
ShapeMismatch: "repeat_by argument and the Series should have equal length, or at least one of them should have length 1. Series length {}, by length {}",
1515
length_srs, length_by
1616
);
1717
Ok(())

Diff for: crates/polars-plan/src/dsl/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ impl Expr {
12521252

12531253
#[cfg(feature = "repeat_by")]
12541254
fn repeat_by_impl(self, by: Expr) -> Expr {
1255-
self.apply_many_private(FunctionExpr::RepeatBy, &[by], false, false)
1255+
self.map_many_private(FunctionExpr::RepeatBy, &[by], false, None)
12561256
}
12571257

12581258
#[cfg(feature = "repeat_by")]

Diff for: py-polars/tests/unit/dataframe/test_df.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1392,11 +1392,7 @@ def test_repeat_by_unequal_lengths_panic() -> None:
13921392
"a": ["x", "y", "z"],
13931393
}
13941394
)
1395-
with pytest.raises(
1396-
ComputeError,
1397-
match="repeat_by argument and the Series should have equal length, "
1398-
"or at least one of them should have length 1",
1399-
):
1395+
with pytest.raises(ShapeError):
14001396
df.select(pl.col("a").repeat_by(pl.Series([2, 2])))
14011397

14021398

0 commit comments

Comments
 (0)