Skip to content

Add type literal to engine argument in rolling functions #54135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions pandas/core/window/expanding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
TYPE_CHECKING,
Any,
Callable,
Literal,
)

from pandas.util._decorators import (
Expand Down Expand Up @@ -231,7 +232,7 @@ def apply(
self,
func: Callable[..., Any],
raw: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
args: tuple[Any, ...] | None = None,
kwargs: dict[str, Any] | None = None,
Expand Down Expand Up @@ -275,7 +276,7 @@ def apply(
def sum(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().sum(
Expand Down Expand Up @@ -314,7 +315,7 @@ def sum(
def max(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().max(
Expand Down Expand Up @@ -353,7 +354,7 @@ def max(
def min(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().min(
Expand Down Expand Up @@ -392,7 +393,7 @@ def min(
def mean(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().mean(
Expand Down Expand Up @@ -431,7 +432,7 @@ def mean(
def median(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().median(
Expand Down Expand Up @@ -490,7 +491,7 @@ def std(
self,
ddof: int = 1,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().std(
Expand Down Expand Up @@ -550,7 +551,7 @@ def var(
self,
ddof: int = 1,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().var(
Expand Down
33 changes: 17 additions & 16 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
TYPE_CHECKING,
Any,
Callable,
Literal,
cast,
)

Expand Down Expand Up @@ -1458,7 +1459,7 @@ def apply(
self,
func: Callable[..., Any],
raw: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
args: tuple[Any, ...] | None = None,
kwargs: dict[str, Any] | None = None,
Expand Down Expand Up @@ -1525,7 +1526,7 @@ def apply_func(values, begin, end, min_periods, raw=raw):
def sum(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand All @@ -1547,7 +1548,7 @@ def sum(
def max(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand All @@ -1569,7 +1570,7 @@ def max(
def min(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand All @@ -1591,7 +1592,7 @@ def min(
def mean(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand All @@ -1613,7 +1614,7 @@ def mean(
def median(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand All @@ -1635,7 +1636,7 @@ def std(
self,
ddof: int = 1,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand All @@ -1659,7 +1660,7 @@ def var(
self,
ddof: int = 1,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
if maybe_use_numba(engine):
Expand Down Expand Up @@ -2021,7 +2022,7 @@ def apply(
self,
func: Callable[..., Any],
raw: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
args: tuple[Any, ...] | None = None,
kwargs: dict[str, Any] | None = None,
Expand Down Expand Up @@ -2101,7 +2102,7 @@ def apply(
def sum(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().sum(
Expand Down Expand Up @@ -2141,7 +2142,7 @@ def max(
self,
numeric_only: bool = False,
*args,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
**kwargs,
):
Expand Down Expand Up @@ -2184,7 +2185,7 @@ def max(
def min(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().min(
Expand Down Expand Up @@ -2233,7 +2234,7 @@ def min(
def mean(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().mean(
Expand Down Expand Up @@ -2275,7 +2276,7 @@ def mean(
def median(
self,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().median(
Expand Down Expand Up @@ -2333,7 +2334,7 @@ def std(
self,
ddof: int = 1,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().std(
Expand Down Expand Up @@ -2392,7 +2393,7 @@ def var(
self,
ddof: int = 1,
numeric_only: bool = False,
engine: str | None = None,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
):
return super().var(
Expand Down