Skip to content

Commit

Permalink
fix: correct minimum Polars version for ewm_mean (#1415)
Browse files Browse the repository at this point in the history
* remove xfail

* testing version

* fix version number

---------

Co-authored-by: Marco Gorelli <[email protected]>
  • Loading branch information
DeaMariaLeon and MarcoGorelli authored Nov 21, 2024
1 parent db9a048 commit 763a4e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions narwhals/_polars/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from narwhals._polars.utils import extract_native
from narwhals._polars.utils import narwhals_to_native_dtype
from narwhals.utils import Implementation
from narwhals.utils import parse_version

if TYPE_CHECKING:
import polars as pl
Expand Down Expand Up @@ -61,10 +60,8 @@ def ewm_mean(
min_periods: int = 1,
ignore_nulls: bool = False,
) -> Self:
import polars as pl # ignore-banned-import()

if parse_version(pl.__version__) <= (0, 20, 31): # pragma: no cover
msg = "`ewm_mean` not implemented for polars older than 0.20.31"
if self._backend_version < (1,): # pragma: no cover
msg = "`ewm_mean` not implemented for polars older than 1.0"
raise NotImplementedError(msg)
expr = self._native_expr
return self._from_native_expr(
Expand Down
4 changes: 2 additions & 2 deletions narwhals/_polars/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def ewm_mean(
min_periods: int = 1,
ignore_nulls: bool = False,
) -> Self:
if self._backend_version < (0, 20, 31): # pragma: no cover
msg = "`ewm_mean` not implemented for polars older than 0.20.31"
if self._backend_version < (1,): # pragma: no cover
msg = "`ewm_mean` not implemented for polars older than 1.0"
raise NotImplementedError(msg)
expr = self._native_series
return self._from_native_series(
Expand Down
10 changes: 5 additions & 5 deletions tests/expr_and_series/ewm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
def test_ewm_mean_expr(request: pytest.FixtureRequest, constructor: Constructor) -> None:
if any(x in str(constructor) for x in ("pyarrow_table_", "dask", "modin")) or (
"polars" in str(constructor) and POLARS_VERSION <= (0, 20, 31)
"polars" in str(constructor) and POLARS_VERSION < (1,)
):
request.applymarker(pytest.mark.xfail)

Expand All @@ -37,7 +37,7 @@ def test_ewm_mean_series(
request: pytest.FixtureRequest, constructor_eager: ConstructorEager
) -> None:
if any(x in str(constructor_eager) for x in ("pyarrow_table_", "modin")) or (
"polars" in str(constructor_eager) and POLARS_VERSION <= (0, 20, 31)
"polars" in str(constructor_eager) and POLARS_VERSION < (1,)
):
request.applymarker(pytest.mark.xfail)

Expand Down Expand Up @@ -76,7 +76,7 @@ def test_ewm_mean_expr_adjust(
expected: dict[str, list[float]],
) -> None:
if any(x in str(constructor) for x in ("pyarrow_table_", "dask", "modin")) or (
"polars" in str(constructor) and POLARS_VERSION <= (0, 20, 31)
"polars" in str(constructor) and POLARS_VERSION < (1,)
):
request.applymarker(pytest.mark.xfail)

Expand Down Expand Up @@ -138,7 +138,7 @@ def test_ewm_mean_nulls(
constructor: Constructor,
) -> None:
if any(x in str(constructor) for x in ("pyarrow_table_", "dask", "modin")) or (
"polars" in str(constructor) and POLARS_VERSION <= (0, 20, 31)
"polars" in str(constructor) and POLARS_VERSION < (1,)
):
request.applymarker(pytest.mark.xfail)

Expand All @@ -155,7 +155,7 @@ def test_ewm_mean_params(
constructor: Constructor,
) -> None:
if any(x in str(constructor) for x in ("pyarrow_table_", "dask", "modin")) or (
"polars" in str(constructor) and POLARS_VERSION <= (0, 20, 31)
"polars" in str(constructor) and POLARS_VERSION < (1,)
):
request.applymarker(pytest.mark.xfail)

Expand Down

0 comments on commit 763a4e3

Please sign in to comment.