Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jan 20, 2025
1 parent 02fbb6c commit ad2df0a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions narwhals/_dask/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ def group_by(self, *by: str, drop_null_keys: bool) -> DaskLazyGroupBy:

return DaskLazyGroupBy(self, list(by), drop_null_keys=drop_null_keys)

def tail(self: Self, n: int) -> Self:
def tail(self: Self, n: int) -> Self: # pragma: no cover
native_frame = self._native_frame
n_partitions = native_frame.npartitions

if n_partitions == 1: # pragma: no cover
if n_partitions == 1:
return self._from_native_frame(self._native_frame.tail(n=n, compute=False))
else:
msg = "`LazyFrame.tail` is not supported for Dask backend with multiple partitions."
Expand Down
2 changes: 1 addition & 1 deletion narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4360,7 +4360,7 @@ def head(self, n: int = 5) -> Self:
"""
return super().head(n)

def tail(self, n: int = 5) -> Self:
def tail(self, n: int = 5) -> Self: # pragma: no cover
r"""Get the last `n` rows.
!!! warning
Expand Down
2 changes: 1 addition & 1 deletion narwhals/stable/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ def unique(self, *, maintain_order: bool | None = None) -> Self:
Returns:
A new expression.
"""
if maintain_order:
if maintain_order: # pragma: no cover
msg = "`maintain_order=True` is not supported for Expr.unique."
raise ValueError(msg)
if maintain_order is not None:
Expand Down
4 changes: 4 additions & 0 deletions tests/expr_and_series/unique_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

import narwhals as nw
import narwhals.stable.v1 as nw_v1
from narwhals.exceptions import LengthChangingExprError
from tests.utils import Constructor
from tests.utils import ConstructorEager
Expand All @@ -26,6 +27,9 @@ def test_unique_expr(constructor: Constructor) -> None:
expected = {"a": [1, 2]}
assert_equal_data(result, expected)

with pytest.warns(UserWarning):
df.select(nw_v1.col("a").unique(maintain_order=False).sum())


def test_unique_expr_agg(
constructor: Constructor, request: pytest.FixtureRequest
Expand Down

0 comments on commit ad2df0a

Please sign in to comment.