Skip to content

Commit

Permalink
feat: raise more informative error messages in rolling_* aggregations…
Browse files Browse the repository at this point in the history
… instead of panicking (pola-rs#15979)
  • Loading branch information
MarcoGorelli authored and Nennia committed May 3, 2024
1 parent 4276b70 commit 396fd23
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions py-polars/tests/unit/operations/rolling/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,3 +1066,13 @@ def test_rolling_duration(time_unit: Literal["ns", "us", "ms"]) -> None:
), f"{res_duration['value'].to_list()=}, {res_datetime['value'].to_list()=}"

assert res_duration["index_column"].dtype == pl.Duration(time_unit=time_unit)


def test_temporal_windows_size_without_by_15977() -> None:
df = pl.DataFrame(
{"a": [1, 2, 3], "b": [date(2020, 1, 1), date(2020, 1, 2), date(2020, 1, 3)]}
)
with pytest.raises(
pl.InvalidOperationError, match="the `by` argument must be passed"
):
df.select(pl.col("a").rolling_mean("3d"))

0 comments on commit 396fd23

Please sign in to comment.