7 from collections
import OrderedDict
10 test_status =
int(os.environ[
"ATLAS_CTEST_TESTSTATUS"])
12 print(f
"Post evaluation: ERROR: previous step went wrong (exit code {test_status})")
15 test_output_file = os.environ[
"ATLAS_CTEST_TESTNAME"]+
".log"
16 bdt_config_file = os.environ[
"TAU_EFEX_BDT_CONFIG_PATH"]
20 Extract a vector of numbers from a line that starts with a string from a list of Athena log file lines
22 vals = [x[x.rfind(
':')+1:].
split()
for x
in lines
if startswith
in x]
23 vals = np.array(vals).astype(int)
26 out_log_content =
open(test_output_file,
"r").
read()
29 bdt_algo_lines = [l
for l
in out_log_content.split(
'\n')
if re.findall(
r"eFEXDriver\..+eFEXtauBDTAlgo", l)]
32 rgx_vartitle = re.compile(
r"DEBUG\s+([0-9]+) is (l[0-4]_d[0-9_pld]*), sum of supercells$")
33 rgx_coretitle = re.compile(
r"DEBUG\s+([0-9]+) is CORE, sum of supercells$")
34 rgx_etaphilayer = re.compile(
r"DEBUG\s+eta=([0-9]+)\s+phi=([0-9]+)\s+layer=([0-9]+)$")
35 variables = OrderedDict()
36 last_var_line = [i
for i,x
in enumerate(bdt_algo_lines)
if "Will use sum of supercells" in x][0]
37 for l
in bdt_algo_lines[:last_var_line]:
38 vartitle = rgx_vartitle.findall(l)
39 coretitle = rgx_coretitle.findall(l)
40 etaphilayer = rgx_etaphilayer.findall(l)
42 variables[vartitle[0][1]] = []
44 elif len(coretitle) > 0:
47 elif len(etaphilayer) > 0:
48 variables[vt].
append([
int(x)
for x
in etaphilayer[0]])
50 bdt_config=json.load(
open(bdt_config_file,
"r"))
52 assert set(v[
'name']
for v
in bdt_config[
'variables']) ==
set(variables.keys()),
"Variables as read from this test's log file are not as they appear in the data/bdt_config.json. They must be consistent with each other."
54 for v
in bdt_config[
'variables']:
55 assert sorted(v[
'scells']) ==
sorted(variables[v[
'name']]), f
"For BDT variable {v['name']}, the supercells used to compute it are different in the log file vs. in data/bdt_config.json"
58 bdt_scores=
get_vector(bdt_algo_lines,
'DEBUG BDT Score: ').reshape(-1)
59 assert ((bdt_scores>500) &(bdt_scores < 2000)).
all()