Skip to content

Commit

Permalink
chore: factor test_std outside test_common (#657)
Browse files Browse the repository at this point in the history
* Moved test_std outside test_common

* Swapped constructor_eager fixture with constructor in test_std
  • Loading branch information
montanarograziano authored Jul 28, 2024
1 parent 302c997 commit ebe37d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ filterwarnings = [
'ignore:.*defaulting to pandas implementation',
'ignore:.*implementation has mismatches with pandas',
'ignore:.*Do not use the `random` module inside strategies',
'ignore:.*You are using pyarrow version 12',
'ignore:.*You are using pyarrow version',
]
xfail_strict = true
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
Expand Down
25 changes: 25 additions & 0 deletions tests/frame/std_test.py
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)
19 changes: 0 additions & 19 deletions tests/frame/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@
data_right = {"c": [6, 12, -1], "d": [0, -4, 2]}


def test_std(constructor_eager: Any) -> None:
df = nw.from_native(constructor_eager(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)


@pytest.mark.filterwarnings("ignore:Determining|Resolving.*")
def test_columns(constructor: Any) -> None:
df = nw.from_native(constructor(data))
Expand Down

0 comments on commit ebe37d9

Please sign in to comment.