forked from narwhals-dev/narwhals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into add-where-expression
- Loading branch information
Showing
18 changed files
with
285 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
- std | ||
- sum | ||
- tail | ||
- to_dummies | ||
- to_frame | ||
- to_list | ||
- to_numpy | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build" | |
|
||
[project] | ||
name = "narwhals" | ||
version = "1.1.3" | ||
version = "1.1.4" | ||
authors = [ | ||
{ name="Marco Gorelli", email="[email protected]" }, | ||
] | ||
|
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,5 +1,5 @@ | ||
covdefaults | ||
ibis-framework | ||
ibis-framework[polars] | ||
pandas | ||
polars[timezones] | ||
pre-commit | ||
|
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Any | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import compare_dicts | ||
|
||
data = {"a": [1, 3, 2], "b": [0, 2, -1]} | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("descending", "expected"), | ||
[ | ||
(True, {"a": [3, 2, 1], "b": [0, 2, -1]}), | ||
(False, {"a": [1, 2, 3], "b": [0, 2, -1]}), | ||
], | ||
) | ||
def test_sort_expr(constructor: Any, descending: Any, expected: Any) -> None: | ||
df = nw.from_native(constructor(data), eager_only=True) | ||
result = df.select(nw.col("a").sort(descending=descending), "b") | ||
compare_dicts(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("descending", "expected"), [(True, [3, 2, 1]), (False, [1, 2, 3])] | ||
) | ||
def test_sort_series(constructor_series: Any, descending: Any, expected: Any) -> None: | ||
series = nw.from_native(constructor_series(data["a"]), series_only=True) | ||
result = series.sort(descending=descending) | ||
assert (result.to_numpy() == np.array(expected)).all() |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Any | ||
|
||
import numpy as np | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import compare_dicts | ||
|
||
data = {"a": [1, 1, 2]} | ||
|
||
|
||
def test_unique_expr(constructor: Any) -> None: | ||
df = nw.from_native(constructor(data), eager_only=True) | ||
result = df.select(nw.col("a").unique()) | ||
expected = {"a": [1, 2]} | ||
compare_dicts(result, expected) | ||
|
||
|
||
def test_unique_series(constructor_series: Any) -> None: | ||
series = nw.from_native(constructor_series(data["a"]), series_only=True) | ||
result = series.unique() | ||
expected = np.array([1, 2]) | ||
assert (result.to_numpy() == expected).all() |
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
Oops, something went wrong.