@@ -92,7 +92,7 @@ def _create_abstract_test_case(self, test, mutates, effects):
92
92
treatment_variable = treatment_var ,
93
93
expected_causal_effect = {
94
94
self .scenario .variables [variable ]: effects [effect ]
95
- for variable , effect in test ["expectedEffect " ].items ()
95
+ for variable , effect in test ["expected_effect " ].items ()
96
96
},
97
97
effect_modifiers = {self .scenario .variables [v ] for v in test ["effect_modifiers" ]}
98
98
if "effect_modifiers" in test
@@ -120,23 +120,23 @@ def run_json_tests(self, effects: dict, estimators: dict, f_flag: bool = False,
120
120
if test ["estimate_type" ] == "coefficient" :
121
121
base_test_case = BaseTestCase (
122
122
treatment_variable = next (self .scenario .variables [v ] for v in test ["mutations" ]),
123
- outcome_variable = next (self .scenario .variables [v ] for v in test ["expectedEffect " ]),
123
+ outcome_variable = next (self .scenario .variables [v ] for v in test ["expected_effect " ]),
124
124
effect = test .get ("effect" , "direct" ),
125
125
)
126
- assert len (test ["expectedEffect " ]) == 1 , "Can only have one expected effect."
126
+ assert len (test ["expected_effect " ]) == 1 , "Can only have one expected effect."
127
127
concrete_tests = [
128
128
CausalTestCase (
129
129
base_test_case = base_test_case ,
130
130
expected_causal_effect = next (
131
- effects [effect ] for variable , effect in test ["expectedEffect " ].items ()
131
+ effects [effect ] for variable , effect in test ["expected_effect " ].items ()
132
132
),
133
133
estimate_type = "coefficient" ,
134
134
effect_modifier_configuration = {
135
135
self .scenario .variables [v ] for v in test .get ("effect_modifiers" , [])
136
136
},
137
137
)
138
138
]
139
- failures = self ._execute_tests (concrete_tests , estimators , test , f_flag )
139
+ failures = self ._execute_tests (concrete_tests , test , f_flag )
140
140
msg = (
141
141
f"Executing test: { test ['name' ]} \n "
142
142
+ f" { concrete_tests [0 ]} \n "
@@ -145,7 +145,8 @@ def run_json_tests(self, effects: dict, estimators: dict, f_flag: bool = False,
145
145
else :
146
146
abstract_test = self ._create_abstract_test_case (test , mutates , effects )
147
147
concrete_tests , dummy = abstract_test .generate_concrete_tests (5 , 0.05 )
148
- failures = self ._execute_tests (concrete_tests , estimators , test , f_flag )
148
+ failures = self ._execute_tests (concrete_tests , test , f_flag )
149
+
149
150
msg = (
150
151
f"Executing test: { test ['name' ]} \n "
151
152
+ " abstract_test \n "
@@ -155,35 +156,35 @@ def run_json_tests(self, effects: dict, estimators: dict, f_flag: bool = False,
155
156
+ f" { failures } /{ len (concrete_tests )} failed for { test ['name' ]} "
156
157
)
157
158
self ._append_to_file (msg , logging .INFO )
158
- else :
159
- outcome_variable = next (
160
- iter (test ["expected_effect" ])
161
- ) # Take first key from dictionary of expected effect
162
- base_test_case = BaseTestCase (
163
- treatment_variable = self .variables ["inputs" ][test ["treatment_variable" ]],
164
- outcome_variable = self .variables ["outputs" ][outcome_variable ],
165
- )
166
-
167
- causal_test_case = CausalTestCase (
168
- base_test_case = base_test_case ,
169
- expected_causal_effect = effects [test ["expected_effect" ][outcome_variable ]],
170
- control_value = test ["control_value" ],
171
- treatment_value = test ["treatment_value" ],
172
- estimate_type = test ["estimate_type" ],
173
- )
174
- if self ._execute_test_case (causal_test_case = causal_test_case , test = test , f_flag = f_flag ):
175
- result = "failed"
176
- else :
177
- result = "passed"
159
+ else :
160
+ outcome_variable = next (
161
+ iter (test ["expected_effect" ])
162
+ ) # Take first key from dictionary of expected effect
163
+ base_test_case = BaseTestCase (
164
+ treatment_variable = self .variables ["inputs" ][test ["treatment_variable" ]],
165
+ outcome_variable = self .variables ["outputs" ][outcome_variable ],
166
+ )
178
167
179
- msg = (
180
- f"Executing concrete test: { test ['name' ]} \n "
181
- + f"treatment variable: { test ['treatment_variable' ]} \n "
182
- + f"outcome_variable = { outcome_variable } \n "
183
- + f"control value = { test ['control_value' ]} , treatment value = { test ['treatment_value' ]} \n "
184
- + f"result - { result } "
185
- )
186
- self ._append_to_file (msg , logging .INFO )
168
+ causal_test_case = CausalTestCase (
169
+ base_test_case = base_test_case ,
170
+ expected_causal_effect = effects [test ["expected_effect" ][outcome_variable ]],
171
+ control_value = test ["control_value" ],
172
+ treatment_value = test ["treatment_value" ],
173
+ estimate_type = test ["estimate_type" ],
174
+ )
175
+ if self ._execute_test_case (causal_test_case = causal_test_case , test = test , f_flag = f_flag ):
176
+ result = "failed"
177
+ else :
178
+ result = "passed"
179
+
180
+ msg = (
181
+ f"Executing concrete test: { test ['name' ]} \n "
182
+ + f"treatment variable: { test ['treatment_variable' ]} \n "
183
+ + f"outcome_variable = { outcome_variable } \n "
184
+ + f"control value = { test ['control_value' ]} , treatment value = { test ['treatment_value' ]} \n "
185
+ + f"result - { result } "
186
+ )
187
+ self ._append_to_file (msg , logging .INFO )
187
188
188
189
def _create_abstract_test_case (self , test , mutates , effects ):
189
190
assert len (test ["mutations" ]) == 1
0 commit comments