-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deprecate
maintain_order
in Expr.unique
and `LazyFrame.tail…
…` (but keep around in `stable.v1`) (#1839)
- Loading branch information
1 parent
b26358b
commit 7a9560b
Showing
13 changed files
with
87 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,16 @@ | ||
from __future__ import annotations | ||
|
||
from contextlib import nullcontext as does_not_raise | ||
|
||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import Constructor | ||
from tests.utils import ConstructorEager | ||
from tests.utils import assert_equal_data | ||
|
||
|
||
def test_tail(request: pytest.FixtureRequest, constructor: Constructor) -> None: | ||
if "pyspark" in str(constructor): | ||
request.applymarker(pytest.mark.xfail) | ||
|
||
def test_tail(constructor_eager: ConstructorEager) -> None: | ||
data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8.0, 9.0]} | ||
expected = {"a": [3, 2], "b": [4, 6], "z": [8.0, 9]} | ||
|
||
df_raw = constructor(data) | ||
df = nw.from_native(df_raw).lazy() | ||
|
||
context = ( | ||
pytest.raises( | ||
NotImplementedError, | ||
match="`LazyFrame.tail` is not supported for Dask backend with multiple partitions.", | ||
) | ||
if "dask_lazy_p2" in str(constructor) | ||
else does_not_raise() | ||
) | ||
|
||
with context: | ||
result = df.tail(2) | ||
assert_equal_data(result, expected) | ||
|
||
result = df.collect().tail(2) # type: ignore[assignment] | ||
assert_equal_data(result, expected) | ||
|
||
result = df.collect().tail(-1) # type: ignore[assignment] | ||
assert_equal_data(result, expected) | ||
|
||
result = df.collect().select(nw.col("a").tail(2)) # type: ignore[assignment] | ||
assert_equal_data(result, {"a": expected["a"]}) | ||
df_raw = constructor_eager(data) | ||
df = nw.from_native(df_raw) | ||
result = df.tail(2) | ||
assert_equal_data(result, expected) | ||
result = df.tail(-1) | ||
assert_equal_data(result, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters