-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved test_std outside test_common * Swapped constructor_eager fixture with constructor in test_std
- Loading branch information
1 parent
302c997
commit ebe37d9
Showing
3 changed files
with
26 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Any | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import compare_dicts | ||
|
||
data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]} | ||
|
||
|
||
def test_std(constructor: Any) -> None: | ||
df = nw.from_native(constructor(data)) | ||
result = df.select( | ||
nw.col("a").std().alias("a_ddof_default"), | ||
nw.col("a").std(ddof=1).alias("a_ddof_1"), | ||
nw.col("a").std(ddof=0).alias("a_ddof_0"), | ||
nw.col("b").std(ddof=2).alias("b_ddof_2"), | ||
nw.col("z").std(ddof=0).alias("z_ddof_0"), | ||
) | ||
expected = { | ||
"a_ddof_default": [1.0], | ||
"a_ddof_1": [1.0], | ||
"a_ddof_0": [0.816497], | ||
"b_ddof_2": [1.632993], | ||
"z_ddof_0": [0.816497], | ||
} | ||
compare_dicts(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