Skip to content

Commit

Permalink
post-merge fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Oct 28, 2023
1 parent da6738b commit 0ff1386
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
5 changes: 0 additions & 5 deletions py-polars/src/expr/rolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{PyExpr, PySeries};
#[pymethods]
impl PyExpr {
#[pyo3(signature = (window_size, weights, min_periods, center, by, closed, warn_if_unsorted))]
#[allow(clippy::too_many_arguments)]
fn rolling_sum(
&self,
window_size: &str,
Expand All @@ -37,7 +36,6 @@ impl PyExpr {
}

#[pyo3(signature = (window_size, weights, min_periods, center, by, closed, warn_if_unsorted))]
#[allow(clippy::too_many_arguments)]
fn rolling_min(
&self,
window_size: &str,
Expand All @@ -62,7 +60,6 @@ impl PyExpr {
}

#[pyo3(signature = (window_size, weights, min_periods, center, by, closed, warn_if_unsorted))]
#[allow(clippy::too_many_arguments)]
fn rolling_max(
&self,
window_size: &str,
Expand All @@ -87,7 +84,6 @@ impl PyExpr {
}

#[pyo3(signature = (window_size, weights, min_periods, center, by, closed, warn_if_unsorted))]
#[allow(clippy::too_many_arguments)]
fn rolling_mean(
&self,
window_size: &str,
Expand Down Expand Up @@ -165,7 +161,6 @@ impl PyExpr {
}

#[pyo3(signature = (window_size, weights, min_periods, center, by, closed, warn_if_unsorted))]
#[allow(clippy::too_many_arguments)]
fn rolling_median(
&self,
window_size: &str,
Expand Down
44 changes: 20 additions & 24 deletions py-polars/tests/parametric/test_groupby_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def test_rolling(


@given(
window_size=st.timedeltas(min_value=timedelta(microseconds=0)).map(
_timedelta_to_pl_duration
),
window_size=st.timedeltas(
min_value=timedelta(microseconds=0), max_value=timedelta(days=2)
).map(_timedelta_to_pl_duration),
closed=strategy_closed,
data=st.data(),
time_unit=strategy_time_unit,
Expand Down Expand Up @@ -114,33 +114,29 @@ def test_rolling_aggs(
# - that even if polars temporarily sorts the data under-the-hood, the
# order that the user passed the data in is restored
assume(window_size != "")
dataframe = data.draw(
df = data.draw(
dataframes(
[
column("ts", dtype=pl.Datetime(time_unit)),
column("value", dtype=pl.Int64),
column(
"ts",
strategy=st.datetimes(
min_value=dt.datetime(2000, 1, 1),
max_value=dt.datetime(2001, 1, 1),
),
dtype=pl.Datetime(time_unit),
),
column(
"value",
strategy=st.integers(min_value=-100, max_value=100),
dtype=pl.Int64,
),
],
)
)
# take unique because of https://github.com/pola-rs/polars/issues/11150
df = dataframe.unique("ts")
func = f"rolling_{aggregation}"
try:
result = df.with_columns(
getattr(pl.col("value"), func)(
window_size=window_size, by="ts", closed=closed, warn_if_unsorted=False
)
)
except pl.exceptions.PolarsPanicError as exc:
assert any( # noqa: PT017
msg in str(exc)
for msg in (
"attempt to multiply with overflow",
"attempt to add with overflow",
)
)
reject()

result = df.with_columns(
getattr(pl.col("value"), func)(window_size=window_size, by="ts", closed=closed)
)
expected = (
df.with_row_count("index")
.sort("ts")
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def test_power() -> None:
assert_series_equal(a**a, pl.Series([1.0, 4.0], dtype=Float64))
assert_series_equal(b**b, pl.Series([None, 4.0], dtype=Float64))
assert_series_equal(a**b, pl.Series([None, 4.0], dtype=Float64))
assert_series_equal(a**None, pl.Series([None] * len(a), dtype=Float64))
assert_series_equal(a ** None, pl.Series([None] * len(a), dtype=Float64))
with pytest.raises(TypeError):
c**2
with pytest.raises(pl.ColumnNotFoundError):
Expand Down

0 comments on commit 0ff1386

Please sign in to comment.