Skip to content

Commit fd44732

Browse files
authored
deps: Bump polars min version to 0.20.4 (#2735)
* deps: Bump polars min version to 0.20.4 * generate_random_version
1 parent 0aea5a6 commit fd44732

File tree

10 files changed

+15
-46
lines changed

10 files changed

+15
-46
lines changed

.github/workflows/extremes.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
cache-suffix: ${{ matrix.python-version }}
2626
cache-dependency-glob: "pyproject.toml"
2727
- name: install-minimum-versions
28-
run: uv pip install pipdeptree tox virtualenv setuptools pandas==1.1.3 polars==0.20.3 numpy==1.19.3 pyarrow==11.0.0 "pyarrow-stubs<17" scipy==1.6.0 scikit-learn==1.1.0 duckdb==1.0 tzdata --system
28+
run: uv pip install pipdeptree tox virtualenv setuptools pandas==1.1.3 polars==0.20.4 numpy==1.19.3 pyarrow==11.0.0 "pyarrow-stubs<17" scipy==1.6.0 scikit-learn==1.1.0 duckdb==1.0 tzdata --system
2929
- name: install-reqs
3030
run: |
3131
uv pip install -e . --group tests --system
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
DEPS=$(uv pip freeze)
3737
echo "$DEPS" | grep 'pandas==1.1.3'
38-
echo "$DEPS" | grep 'polars==0.20.3'
38+
echo "$DEPS" | grep 'polars==0.20.4'
3939
echo "$DEPS" | grep 'numpy==1.19.3'
4040
echo "$DEPS" | grep 'pyarrow==11.0.0'
4141
echo "$DEPS" | grep 'scipy==1.6.0'
@@ -62,7 +62,7 @@ jobs:
6262
cache-suffix: ${{ matrix.python-version }}
6363
cache-dependency-glob: "pyproject.toml"
6464
- name: install-pretty-old-versions
65-
run: uv pip install pipdeptree tox virtualenv setuptools pandas==1.1.5 polars==0.20.3 numpy==1.19.3 pyarrow==11.0.0 "pyarrow-stubs<17" scipy==1.6.0 scikit-learn==1.1.0 duckdb==1.0 tzdata --system
65+
run: uv pip install pipdeptree tox virtualenv setuptools pandas==1.1.5 polars==0.20.4 numpy==1.19.3 pyarrow==11.0.0 "pyarrow-stubs<17" scipy==1.6.0 scikit-learn==1.1.0 duckdb==1.0 tzdata --system
6666
- name: install-reqs
6767
run: uv pip install -e . --group tests --system
6868
- name: show-deps
@@ -73,7 +73,7 @@ jobs:
7373
run : |
7474
DEPS=$(uv pip freeze)
7575
echo "$DEPS" | grep 'pandas==1.1.5'
76-
echo "$DEPS" | grep 'polars==0.20.3'
76+
echo "$DEPS" | grep 'polars==0.20.4'
7777
echo "$DEPS" | grep 'numpy==1.19.3'
7878
echo "$DEPS" | grep 'pyarrow==11.0.0'
7979
echo "$DEPS" | grep 'scipy==1.6.0'

narwhals/_polars/dataframe.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,7 @@ def collect_schema(self) -> dict[str, DType]:
239239
def with_row_index(self, name: str, order_by: Sequence[str] | None) -> Self:
240240
frame = self.native
241241
if order_by is None:
242-
result = (
243-
frame.with_row_count(name)
244-
if self._backend_version < (0, 20, 4)
245-
else frame.with_row_index(name)
246-
)
242+
result = frame.with_row_index(name)
247243
else:
248244
end = pl.count() if self._backend_version < (0, 20, 5) else pl.len()
249245
result = frame.select(

narwhals/_polars/expr.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,7 @@ def __invert__(self) -> Self:
216216
return self._with_native(self.native.__invert__())
217217

218218
def cum_count(self, *, reverse: bool) -> Self:
219-
if self._backend_version < (0, 20, 4):
220-
result = (~self.native.is_null()).cum_sum(reverse=reverse)
221-
else:
222-
result = self.native.cum_count(reverse=reverse)
223-
return self._with_native(result)
219+
return self._with_native(self.native.cum_count(reverse=reverse))
224220

225221
def __narwhals_expr__(self) -> None: ...
226222
def __narwhals_namespace__(self) -> PolarsNamespace: # pragma: no cover

narwhals/_polars/series.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,7 @@ def value_counts(
468468
return PolarsDataFrame.from_native(result, context=self)
469469

470470
def cum_count(self, *, reverse: bool) -> Self:
471-
if self._backend_version < (0, 20, 4):
472-
not_null_series = ~self.native.is_null()
473-
result = not_null_series.cum_sum(reverse=reverse)
474-
else:
475-
result = self.native.cum_count(reverse=reverse)
476-
477-
return self._with_native(result)
471+
return self._with_native(self.native.cum_count(reverse=reverse))
478472

479473
def __contains__(self, other: Any) -> bool:
480474
try:

narwhals/_polars/utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from functools import lru_cache
4-
from typing import TYPE_CHECKING, Any, TypeVar, cast, overload
4+
from typing import TYPE_CHECKING, Any, TypeVar, overload
55

66
import polars as pl
77

@@ -97,11 +97,7 @@ def native_to_narwhals_dtype( # noqa: C901, PLR0912
9797
if isinstance_or_issubclass(dtype, pl.Enum):
9898
if version is Version.V1:
9999
return dtypes.Enum() # type: ignore[call-arg]
100-
categories = _DeferredIterable(
101-
dtype.categories.to_list
102-
if backend_version >= (0, 20, 4)
103-
else lambda: cast("list[str]", dtype.categories)
104-
)
100+
categories = _DeferredIterable(dtype.categories.to_list)
105101
return dtypes.Enum(categories)
106102
if dtype == pl.Date:
107103
return dtypes.Date()

narwhals/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def _backend_version(self) -> tuple[int, ...]:
607607
Implementation.PYARROW: (11,),
608608
Implementation.PYSPARK: (3, 5),
609609
Implementation.PYSPARK_CONNECT: (3, 5),
610-
Implementation.POLARS: (0, 20, 3),
610+
Implementation.POLARS: (0, 20, 4),
611611
Implementation.DASK: (2024, 8),
612612
Implementation.DUCKDB: (1,),
613613
Implementation.IBIS: (6,),

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def pytest_coverage(session: Session) -> None:
4646
def min_and_old_versions(session: Session, pandas_version: str) -> None:
4747
session.install(
4848
f"pandas=={pandas_version}",
49-
"polars==0.20.3",
49+
"polars==0.20.4",
5050
"numpy==1.17.5",
5151
"pyarrow==11.0.0",
5252
"scipy==1.5.0",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cudf = ["cudf>=24.10.0"]
4040
pyarrow = ["pyarrow>=11.0.0"]
4141
pyspark = ["pyspark>=3.5.0"]
4242
pyspark-connect = ["pyspark[connect]>=3.5.0"]
43-
polars = ["polars>=0.20.3"]
43+
polars = ["polars>=0.20.4"]
4444
dask = ["dask[dataframe]>=2024.8"]
4545
duckdb = ["duckdb>=1.0"]
4646
ibis = ["ibis-framework>=6.0.0", "rich", "packaging", "pyarrow_hotfix"]
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from __future__ import annotations
22

3-
import pytest
4-
53
import narwhals as nw
6-
from tests.utils import POLARS_VERSION, ConstructorEager, assert_equal_data
4+
from tests.utils import ConstructorEager, assert_equal_data
75

86
data = {"a": [1, 2, 3], "b": [4, 5, 6], "z": [7.0, 8.0, 9.0]}
97

@@ -14,12 +12,7 @@ def test_map_batches_expr(constructor_eager: ConstructorEager) -> None:
1412
assert_equal_data(expected, {"a": [2, 3, 4], "b": [5, 6, 7]})
1513

1614

17-
def test_map_batches_expr_numpy(
18-
request: pytest.FixtureRequest, constructor_eager: ConstructorEager
19-
) -> None:
20-
if "polars" in str(constructor_eager) and POLARS_VERSION <= (0, 20, 3):
21-
request.applymarker(pytest.mark.xfail)
22-
15+
def test_map_batches_expr_numpy(constructor_eager: ConstructorEager) -> None:
2316
df = nw.from_native(constructor_eager(data))
2417
expected = df.select(
2518
nw.col("a")
@@ -32,12 +25,7 @@ def test_map_batches_expr_numpy(
3225
assert_equal_data(expected, {"a": [2], "b": [2], "z": [2]})
3326

3427

35-
def test_map_batches_expr_names(
36-
request: pytest.FixtureRequest, constructor_eager: ConstructorEager
37-
) -> None:
38-
if "polars" in str(constructor_eager) and POLARS_VERSION <= (0, 20, 3):
39-
request.applymarker(pytest.mark.xfail)
40-
28+
def test_map_batches_expr_names(constructor_eager: ConstructorEager) -> None:
4129
df = nw.from_native(constructor_eager(data))
4230
expected = nw.from_native(df.select(nw.all().map_batches(lambda x: x.to_numpy())))
4331
assert_equal_data(expected, {"a": [1, 2, 3], "b": [4, 5, 6], "z": [7.0, 8.0, 9.0]})

utils/generate_random_versions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
("2.2.2", "1.26.4"),
1414
]
1515
POLARS_VERSION = [
16-
"0.20.3",
1716
"0.20.4",
1817
"0.20.5",
1918
"0.20.6",

0 commit comments

Comments
 (0)