Skip to content

Commit 72a38c7

Browse files
committed
Add check for get_metrics inputs
1 parent 83eb3bd commit 72a38c7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_metrics.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,35 @@ def test_single_value_formats():
162162
assert isinstance(_wss([1,1,0,0], 0.5), float)
163163
assert isinstance(_loss_value([1,1,0,0]), float)
164164
assert isinstance(_erf([1,1,0,0], 0.5), float)
165+
166+
def test_get_metrics():
167+
with open_state(
168+
Path(TEST_ASREVIEW_FILES, "sim_van_de_schoot_2017_stop_if_min.asreview")
169+
) as s:
170+
metrics = get_metrics(s, wss=[0.75, 0.85, 0.95], erf=[0.75, 0.85, 0.95])
171+
172+
wss_data = next(
173+
(item["value"] for item in metrics["data"]["items"] if item["id"] == "wss"),
174+
None
175+
)
176+
assert wss_data is not None, "WSS key missing in metrics"
177+
178+
erf_data = next(
179+
(item["value"] for item in metrics["data"]["items"] if item["id"] == "erf"),
180+
None
181+
)
182+
assert erf_data is not None, "ERF key missing in metrics"
183+
184+
wss_values = {val[0]: val[1] for val in wss_data}
185+
for value in [0.75, 0.85, 0.95]:
186+
assert value in wss_values, f"WSS value {value} missing in output"
187+
188+
for wss_score in wss_values.values():
189+
assert 0 <= wss_score <= 1, f"WSS value {wss_score} out of expected range"
190+
191+
erf_values = {val[0]: val[1] for val in wss_data}
192+
for value in [0.75, 0.85, 0.95]:
193+
assert value in erf_values, f"ERF value {value} missing in output"
194+
195+
for erf_score in erf_values.values():
196+
assert 0 <= erf_score <= 1, f"ERF value {wss_score} out of expected range"

0 commit comments

Comments
 (0)