Skip to content

Commit 839ec31

Browse files
committed
tutorails and ok/not_ok assignment fixed
1 parent a22e5b1 commit 839ec31

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

hypex/reporters/abstract.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,22 @@ def _get_struct_dict(data: dict):
104104

105105
@staticmethod
106106
def _convert_struct_dict_to_dataset(data: dict) -> Dataset:
107+
def _is_truthy(v) -> bool:
108+
"""Return True iff v represents a truthy pass value.
109+
110+
Handles the case where transpose().to_records() stringifies booleans
111+
(e.g. numpy.bool_(False) → "False"), so a plain bool() check would
112+
incorrectly treat the non-empty string "False" as True.
113+
"""
114+
if v is None:
115+
return False
116+
if isinstance(v, str):
117+
return v.lower() == "true"
118+
return bool(v)
119+
107120
def rename_passed(data: dict[str, bool]):
108121
return {
109-
c: (
110-
("NOT OK" if (v is not None and bool(v)) else "OK")
111-
if "pass" in c
112-
else v
113-
)
122+
c: (("NOT OK" if _is_truthy(v) else "OK") if "pass" in c else v)
114123
for c, v in data.items()
115124
}
116125

tests/test_tutorials.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def matching_data():
8181

8282
def test_aatest(aa_data):
8383
mapping = {
84-
"aa-casual": AATest(n_iterations=10),
84+
"aa-casual": AATest(random_states=[56, 72, 2, 43]),
8585
"aa-rs": AATest(random_states=[56, 72, 2, 43]),
8686
"aa-strat": AATest(stratification=True, random_states=[56, 72, 2, 43]),
87-
"aa-sample": AATest(n_iterations=10, sample_size=0.3),
88-
"aa-cat_target": AATest(n_iterations=10),
89-
"aa-equal_var": AATest(n_iterations=10, t_test_equal_var=False),
90-
"aa-n": AATest(n_iterations=10, groups_sizes=[0.5, 0.2, 0.3]),
87+
"aa-sample": AATest(sample_size=0.3, random_states=[56, 72, 2, 43]),
88+
"aa-cat_target": AATest(random_states=[56, 72, 2, 43]),
89+
"aa-equal_var": AATest(equal_variance=False, random_states=[56, 72, 2, 43]),
90+
"aa-n": AATest(groups_sizes=[0.5, 0.2, 0.3], random_states=[56, 72, 2, 43]),
9191
}
9292

9393
mapping_resume = {
@@ -122,7 +122,7 @@ def test_aatest(aa_data):
122122
{
123123
"TTest aa test": {0: "OK", 1: "OK"},
124124
"KSTest aa test": {0: "OK", 1: "OK"},
125-
"TTest best split": {0: "NOT OK", 1: "NOT OK"},
125+
"TTest best split": {0: "OK", 1: "OK"},
126126
"KSTest best split": {0: "OK", 1: "OK"},
127127
"result": {0: "OK", 1: "OK"},
128128
}
@@ -150,7 +150,7 @@ def test_aatest(aa_data):
150150
"aa-n": pd.DataFrame(
151151
{
152152
"TTest aa test": {0: "OK", 1: "OK", 2: "OK", 3: "OK"},
153-
"KSTest aa test": {0: "OK", 1: "OK", 2: "OK", 3: "OK"},
153+
"KSTest aa test": {0: "NOT OK", 1: "NOT OK", 2: "OK", 3: "OK"},
154154
"TTest best split": {0: "OK", 1: "OK", 2: "OK", 3: "OK"},
155155
"KSTest best split": {0: "OK", 1: "OK", 2: "OK", 3: "OK"},
156156
"result": {0: "OK", 1: "OK", 2: "OK", 3: "OK"},

0 commit comments

Comments
 (0)