1+ from typing import Any , cast
2+
13import numpy as np
24
35from rtichoke ._viz_spec_v2 import (
@@ -24,6 +26,7 @@ def test_roc_v2_one_model_one_population():
2426 performance_data ,
2527 _static_metadata (probs , reals ),
2628 )
29+ spec = cast (dict [str , Any ], spec )
2730
2831 assert spec ["schemaVersion" ] == "2.0"
2932 assert spec ["type" ] == "roc"
@@ -57,6 +60,7 @@ def test_roc_v2_multiple_models_share_one_population():
5760 performance_data ,
5861 _static_metadata (probs , reals ),
5962 )
63+ spec = cast (dict [str , Any ], spec )
6064
6165 evaluations = spec ["evaluations" ]
6266 assert [evaluation ["id" ] for evaluation in evaluations ] == [
@@ -87,6 +91,7 @@ def test_roc_v2_keyed_populations_keep_model_identity_unknown():
8791 performance_data ,
8892 _static_metadata (probs , reals ),
8993 )
94+ spec = cast (dict [str , Any ], spec )
9095
9196 assert spec ["evaluations" ] == [
9297 {"id" : "evaluation-1" , "population" : "Population A" },
@@ -112,6 +117,7 @@ def test_roc_v2_ids_do_not_encode_compatibility_group_labels():
112117 prepare_performance_data (probs , reals , by = 0.25 ),
113118 _static_metadata (probs , reals ),
114119 )
120+ spec = cast (dict [str , Any ], spec )
115121
116122 renamed_reals = {
117123 "Cohort X" : reals ["Population A" ],
@@ -125,6 +131,7 @@ def test_roc_v2_ids_do_not_encode_compatibility_group_labels():
125131 prepare_performance_data (renamed_probs , renamed_reals , by = 0.25 ),
126132 _static_metadata (renamed_probs , renamed_reals ),
127133 )
134+ renamed_spec = cast (dict [str , Any ], renamed_spec )
128135
129136 assert [evaluation ["id" ] for evaluation in spec ["evaluations" ]] == [
130137 evaluation ["id" ] for evaluation in renamed_spec ["evaluations" ]
@@ -142,6 +149,7 @@ def test_gains_v2_uses_production_prevalence_for_perfect_path():
142149 spec = _gains_v2_spec_from_performance_data (
143150 performance_data , _static_metadata (probs , reals )
144151 )
152+ spec = cast (dict [str , Any ], spec )
145153
146154 assert spec ["type" ] == "gains"
147155 assert spec ["x" ] == "ppcr"
@@ -171,6 +179,7 @@ def test_gains_v2_shares_one_perfect_path_across_models():
171179 prepare_performance_data (probs , reals , by = 0.25 ),
172180 _static_metadata (probs , reals ),
173181 )
182+ spec = cast (dict [str , Any ], spec )
174183
175184 assert len (spec ["series" ]) == 2
176185 assert len (spec ["references" ]) == 2
@@ -191,6 +200,7 @@ def test_gains_v2_keeps_equal_prevalence_populations_distinct():
191200 prepare_performance_data (probs , reals , by = 0.25 ),
192201 _static_metadata (probs , reals ),
193202 )
203+ spec = cast (dict [str , Any ], spec )
194204
195205 perfect = spec ["references" ][1 :]
196206 assert [reference ["population" ] for reference in perfect ] == [
0 commit comments