Skip to content

Commit

Permalink
feat(python): Mark min_periods as keyword-only for rolling methods (
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored Jun 5, 2024
1 parent 077fda0 commit e75ece9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
20 changes: 10 additions & 10 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7294,8 +7294,8 @@ def rolling_min(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -7525,8 +7525,8 @@ def rolling_max(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -7782,8 +7782,8 @@ def rolling_mean(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -8041,8 +8041,8 @@ def rolling_sum(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -8298,8 +8298,8 @@ def rolling_std(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -8556,8 +8556,8 @@ def rolling_var(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -8814,8 +8814,8 @@ def rolling_median(
self,
window_size: int | timedelta | str,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -8991,8 +8991,8 @@ def rolling_quantile(
interpolation: RollingInterpolationMethod = "nearest",
window_size: int | timedelta | str = 2,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
by: str | None = None,
closed: ClosedInterval | None = None,
Expand Down Expand Up @@ -9244,8 +9244,8 @@ def rolling_map(
function: Callable[[Series], Any],
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Self:
"""
Expand Down Expand Up @@ -10882,7 +10882,7 @@ def entropy(self, base: float = math.e, *, normalize: bool = True) -> Self:

@unstable()
def cumulative_eval(
self, expr: Expr, min_periods: int = 1, *, parallel: bool = False
self, expr: Expr, *, min_periods: int = 1, parallel: bool = False
) -> Self:
"""
Run an expression over a sliding window that increases `1` slot every iteration.
Expand Down
44 changes: 26 additions & 18 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2748,7 +2748,7 @@ def entropy(self, base: float = math.e, *, normalize: bool = False) -> float | N

@unstable()
def cumulative_eval(
self, expr: Expr, min_periods: int = 1, *, parallel: bool = False
self, expr: Expr, *, min_periods: int = 1, parallel: bool = False
) -> Series:
"""
Run an expression over a sliding window that increases `1` slot every iteration.
Expand Down Expand Up @@ -5587,8 +5587,8 @@ def rolling_min(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -5639,7 +5639,7 @@ def rolling_min(
self.to_frame()
.select(
F.col(self.name).rolling_min(
window_size, weights, min_periods, center=center
window_size, weights, min_periods=min_periods, center=center
)
)
.to_series()
Expand All @@ -5650,8 +5650,8 @@ def rolling_max(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -5702,7 +5702,7 @@ def rolling_max(
self.to_frame()
.select(
F.col(self.name).rolling_max(
window_size, weights, min_periods, center=center
window_size, weights, min_periods=min_periods, center=center
)
)
.to_series()
Expand All @@ -5713,8 +5713,8 @@ def rolling_mean(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -5765,7 +5765,7 @@ def rolling_mean(
self.to_frame()
.select(
F.col(self.name).rolling_mean(
window_size, weights, min_periods, center=center
window_size, weights, min_periods=min_periods, center=center
)
)
.to_series()
Expand All @@ -5776,8 +5776,8 @@ def rolling_sum(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -5828,7 +5828,7 @@ def rolling_sum(
self.to_frame()
.select(
F.col(self.name).rolling_sum(
window_size, weights, min_periods, center=center
window_size, weights, min_periods=min_periods, center=center
)
)
.to_series()
Expand All @@ -5839,8 +5839,8 @@ def rolling_std(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
ddof: int = 1,
) -> Series:
Expand Down Expand Up @@ -5895,7 +5895,11 @@ def rolling_std(
self.to_frame()
.select(
F.col(self.name).rolling_std(
window_size, weights, min_periods, center=center, ddof=ddof
window_size,
weights,
min_periods=min_periods,
center=center,
ddof=ddof,
)
)
.to_series()
Expand All @@ -5906,8 +5910,8 @@ def rolling_var(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
ddof: int = 1,
) -> Series:
Expand Down Expand Up @@ -5962,7 +5966,11 @@ def rolling_var(
self.to_frame()
.select(
F.col(self.name).rolling_var(
window_size, weights, min_periods, center=center, ddof=ddof
window_size,
weights,
min_periods=min_periods,
center=center,
ddof=ddof,
)
)
.to_series()
Expand All @@ -5974,8 +5982,8 @@ def rolling_map(
function: Callable[[Series], Any],
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -6030,8 +6038,8 @@ def rolling_median(
self,
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -6082,7 +6090,7 @@ def rolling_median(
self.to_frame()
.select(
F.col(self.name).rolling_median(
window_size, weights, min_periods, center=center
window_size, weights, min_periods=min_periods, center=center
)
)
.to_series()
Expand All @@ -6095,8 +6103,8 @@ def rolling_quantile(
interpolation: RollingInterpolationMethod = "nearest",
window_size: int = 2,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
min_periods: int | None = None,
center: bool = False,
) -> Series:
"""
Expand Down Expand Up @@ -6166,7 +6174,7 @@ def rolling_quantile(
interpolation,
window_size,
weights,
min_periods,
min_periods=min_periods,
center=center,
)
)
Expand Down

0 comments on commit e75ece9

Please sign in to comment.