Skip to content
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
7 changes: 5 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ jobs:
os: [ubuntu-latest]
include:
- python-version: "3.11"
polars_streaming: true
# Polars>=2 collects with the streaming engine by default
polars_engine: in-memory
runs-on: ${{ matrix.os }}
env:
NARWHALS_POLARS_NEW_STREAMING: ${{ matrix.polars_streaming == true }}
NARWHALS_POLARS_ENGINE: ${{ matrix.polars_engine }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -121,6 +122,8 @@ jobs:
run: make run-ci DEPS="-U --group tests --extra pandas --extra pyarrow" RUN_ONLY="--isolated" CMD="pytest tests --runslow --constructors=pandas[pyarrow],pyarrow"
- name: Run pytest (polars)
run: make run-ci DEPS="-U --group tests --extra polars" RUN_ONLY="--isolated" CMD="pytest tests --runslow --constructors=polars[eager],polars[lazy]"
- name: Run pytest (polars<2)
run: make run-ci DEPS="-U --group tests --extra polars" RUN_ONLY="--isolated --with 'polars>=1.44,<2'" CMD="pytest tests --runslow --constructors=polars[eager],polars[lazy]"

python-314:
if: github.head_ref != 'bump-version'
Expand Down
4 changes: 2 additions & 2 deletions src/narwhals/_polars/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def join(
return self._with_native(
self.native.join(
other=other_native,
how=how_native,
how=how_native, # type: ignore[arg-type]
left_on=left_on,
right_on=right_on,
suffix=suffix,
Expand Down Expand Up @@ -276,7 +276,7 @@ def unpivot(
) -> Self:
if self._backend_version < (1, 0, 0):
return self._with_native(
self.native.melt(
self.native.melt( # type: ignore[attr-defined]
id_vars=index,
value_vars=on,
variable_name=variable_name,
Expand Down
2 changes: 1 addition & 1 deletion src/narwhals/_polars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def native_to_narwhals_dtype( # noqa: C901, PLR0912
if isinstance(dtype, pl.List):
return dtypes.List(native_to_narwhals_dtype(dtype.inner, version))
if isinstance(dtype, pl.Array):
outer_shape = dtype.width if BACKEND_VERSION < (0, 20, 30) else dtype.size
outer_shape = dtype.width if BACKEND_VERSION < (0, 20, 30) else dtype.size # type: ignore[attr-defined]
return dtypes.Array(native_to_narwhals_dtype(dtype.inner, version), outer_shape)
if isinstance(dtype, pl.Decimal):
return dtypes.Decimal(dtype.precision, dtype.scale)
Expand Down
2 changes: 1 addition & 1 deletion src/narwhals/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ def is_ordered_categorical(series: Series[Any]) -> bool:
# NOTE: Deprecated https://github.com/pola-rs/polars/pull/23779
# Since version 1.32.0, ordering parameter is ignored and
# it always behaves as if 'lexical' was passed.
result = cast("pl.Categorical", native.dtype).ordering == "physical"
result = cast("pl.Categorical", native.dtype).ordering == "physical" # type: ignore[attr-defined]
elif impl.is_pandas_like():
result = bool(native.cat.ordered)
elif impl.is_pyarrow():
Expand Down
4 changes: 0 additions & 4 deletions tests/expr_and_series/is_close_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
)
from tests.utils import (
PANDAS_VERSION,
POLARS_VERSION,
PYARROW_VERSION,
Constructor,
ConstructorEager,
Expand Down Expand Up @@ -266,9 +265,6 @@ def test_is_close_pandas_unnamed() -> None:
def test_issue_3474_series_decimal(constructor_eager: ConstructorEager) -> None:
frame = nw.from_native(constructor_eager({"a": [0, 1, 2]}))

if frame.implementation.is_polars() and POLARS_VERSION >= (2,): # pragma: no cover
pytest.xfail("Polars >=2.0 rejects is_nan on Decimal")

if frame.implementation.is_pandas_like() and (
PYARROW_VERSION == (0, 0, 0) or PANDAS_VERSION < (2, 2)
):
Expand Down
8 changes: 4 additions & 4 deletions tests/expr_and_series/list/contains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def test_contains_chunked(
monkeypatch: pytest.MonkeyPatch,
) -> None:
skip_or_xfail_unsupported(request, constructor_eager)
if "polars" in str(constructor_eager) and POLARS_VERSION >= (1, 44):
# TODO(Unassigned): Drop once https://github.com/pola-rs/polars/pull/29635 is
# released. Not strict, as only some CPUs hit the bug: arm64 does, while the
# x86_64 CI runners don't.
if "polars" in str(constructor_eager) and (1, 44) <= POLARS_VERSION < (2,):
# Fixed in Polars 2.0 (https://github.com/pola-rs/polars/pull/29635). Not
# strict, as only some CPUs hit the bug: arm64 does, while the x86_64 CI
# runners don't.
reason = "Polars 1.44 mixes up chunks that are slices of the same list array."
request.applymarker(pytest.mark.xfail(reason=reason, strict=False))
pytest.importorskip("pyarrow")
Expand Down
2 changes: 1 addition & 1 deletion tests/series_only/is_ordered_categorical_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_is_ordered_categorical_polars() -> None:
assert not nw.is_ordered_categorical(nw.from_native(s, series_only=True))

cat_dtype = (
pl.Categorical(ordering="lexical")
pl.Categorical(ordering="lexical") # type: ignore[call-arg]
if POLARS_VERSION < (1, 32)
else pl.Categorical()
)
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def assert_equal_data(result: Any, expected: Mapping[str, Any]) -> None:

if os.environ.get("NARWHALS_POLARS_GPU", None): # pragma: no cover
kwargs[Implementation.POLARS].update({"engine": "gpu"})
if os.environ.get("NARWHALS_POLARS_NEW_STREAMING", None): # pragma: no cover
kwargs[Implementation.POLARS].update({"engine": "streaming"})
if engine := os.environ.get("NARWHALS_POLARS_ENGINE"): # pragma: no cover
kwargs[Implementation.POLARS].update({"engine": engine})

result = result.collect(**kwargs.get(result.implementation, {}))

Expand Down
Loading
Loading