-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved/renamed test_expr_unary to expr/unary_test::test_unary (#486)
* Moved/renamed test_expr_unary to expr/unary_test::test_unary * Update tests/expr/unary_test.py Co-authored-by: Francesco Bruzzesi <[email protected]> --------- Co-authored-by: Marco Edward Gorelli <[email protected]> Co-authored-by: Francesco Bruzzesi <[email protected]>
- Loading branch information
1 parent
7e72d88
commit e5dc474
Showing
2 changed files
with
22 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Any | ||
|
||
import narwhals as nw | ||
from tests.utils import compare_dicts | ||
|
||
|
||
def test_unary(constructor_with_lazy: Any) -> None: | ||
data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]} | ||
result = ( | ||
nw.from_native(constructor_with_lazy(data)) | ||
.with_columns( | ||
a_mean=nw.col("a").mean(), | ||
a_sum=nw.col("a").sum(), | ||
b_nunique=nw.col("b").n_unique(), | ||
z_min=nw.col("z").min(), | ||
z_max=nw.col("z").max(), | ||
) | ||
.select(nw.col("a_mean", "a_sum", "b_nunique", "z_min", "z_max").unique()) | ||
) | ||
result_native = nw.to_native(result) | ||
expected = {"a_mean": [2], "a_sum": [6], "b_nunique": [2], "z_min": [7], "z_max": [9]} | ||
compare_dicts(result_native, 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