@@ -110,10 +110,9 @@ def generate_tests(self, effects: dict, mutates: dict, estimators: dict, f_flag:
110
110
f"abstract_test \n " + \
111
111
f"{ abstract_test } \n " + \
112
112
f"{ abstract_test .treatment_variable .name } ,{ abstract_test .treatment_variable .distribution } \n " + \
113
- f"Number of concrete tests for test case: { str (len (concrete_tests ))} "
114
-
115
- self .append_to_file (msg , logging .INFO )
116
-
113
+ f"Number of concrete tests for test case: { str (len (concrete_tests ))} \n " + \
114
+ f"{ failures } /{ len (concrete_tests )} failed for { test ['name' ]} "
115
+ self ._append_to_file (msg , logging .INFO )
117
116
118
117
def _execute_tests (self , concrete_tests , estimators , test , f_flag ):
119
118
failures = 0
@@ -123,7 +122,6 @@ def _execute_tests(self, concrete_tests, estimators, test, f_flag):
123
122
failures += 1
124
123
return failures
125
124
126
-
127
125
def _json_parse (self ):
128
126
"""Parse a JSON input file into inputs, outputs, metas and a test plan"""
129
127
with open (self .input_paths .json_path , encoding = "utf-8" ) as f :
@@ -133,7 +131,6 @@ def _json_parse(self):
133
131
self .data .append (df )
134
132
self .data = pd .concat (self .data )
135
133
136
-
137
134
def _populate_metas (self ):
138
135
"""
139
136
Populate data with meta-variable values and add distributions to Causal Testing Framework Variables
@@ -146,8 +143,7 @@ def _populate_metas(self):
146
143
fitter .fit ()
147
144
(dist , params ) = list (fitter .get_best (method = "sumsquare_error" ).items ())[0 ]
148
145
var .distribution = getattr (scipy .stats , dist )(** params )
149
- self .append_to_file (var .name + f" { dist } ({ params } )" , logging .INFO )
150
-
146
+ self ._append_to_file (var .name + f" { dist } ({ params } )" , logging .INFO )
151
147
152
148
def _execute_test_case (self , causal_test_case : CausalTestCase , estimator : Estimator , f_flag : bool ) -> bool :
153
149
"""Executes a singular test case, prints the results and returns the test case result
@@ -181,11 +177,10 @@ def _execute_test_case(self, causal_test_case: CausalTestCase, estimator: Estima
181
177
)
182
178
if not test_passes :
183
179
failed = True
184
- self .append_to_file (f"FAILED- expected { causal_test_case .expected_causal_effect } , got { result_string } " ,
185
- logging .WARNING )
180
+ self ._append_to_file (f"FAILED- expected { causal_test_case .expected_causal_effect } , got { result_string } " ,
181
+ logging .WARNING )
186
182
return failed
187
183
188
-
189
184
def _setup_test (self , causal_test_case : CausalTestCase , estimator : Estimator ) -> tuple [CausalTestEngine , Estimator ]:
190
185
"""Create the necessary inputs for a single test case
191
186
:param causal_test_case: The concrete test case to be executed
@@ -214,28 +209,24 @@ def _setup_test(self, causal_test_case: CausalTestCase, estimator: Estimator) ->
214
209
215
210
return causal_test_engine , estimation_model
216
211
217
-
218
212
def add_modelling_assumptions (self , estimation_model : Estimator ): # pylint: disable=unused-argument
219
213
"""Optional abstract method where user functionality can be written to determine what assumptions are required
220
214
for specific test cases
221
215
:param estimation_model: estimator model instance for the current running test.
222
216
"""
223
217
return
224
218
225
-
226
- def append_to_file (self , line : str , log_level : int = None ):
219
+ def _append_to_file (self , line : str , log_level : int = None ):
227
220
with open (self .output_path , "a" ) as f :
228
- f .write (line + "\n " )
221
+ f .write (line + "\n " )
229
222
if log_level :
230
223
logger .log (level = log_level , msg = line )
231
224
232
-
233
225
@staticmethod
234
226
def check_file_exists (output_path : Path , overwrite : bool ):
235
227
if not overwrite and output_path .is_file ():
236
228
raise FileExistsError (f"Chosen file output ({ output_path } ) already exists" )
237
229
238
-
239
230
@staticmethod
240
231
def get_args (test_args = None ) -> argparse .Namespace :
241
232
"""Command-line arguments
0 commit comments