-
Notifications
You must be signed in to change notification settings - Fork 1
/
compute_mean_distances.py
46 lines (35 loc) · 1.24 KB
/
compute_mean_distances.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pathlib
import sys
import compare_diags
from main import set_env_and_run
def main():
backend_ref = "DiscreteMorseSandwich"
cpx = "expl"
p = pathlib.Path("diagrams")
backends = set()
for diag_ref in sorted(p.glob(f"*{cpx}_{backend_ref}*")):
ds_root = "_".join(diag_ref.stem.split("_")[:-1])
for diag in sorted(p.glob(f"{ds_root}*")):
if backend_ref in diag.name:
continue
backends.add(diag.stem.split("_")[-1])
backends = sorted(list(backends))
print(backends)
dists = {}
for bk in backends:
for diag_ref in sorted(p.glob(f"*{cpx}_{backend_ref}*")):
ds_root = "_".join(diag_ref.stem.split("_")[:-1])
ds_bk = f"{ds_root}_{bk}"
for diag in sorted(p.glob(f"*{ds_bk}*")):
res = compare_diags.main(str(diag_ref), str(diag), False)
dists.setdefault(bk, []).append(sum(res.values()))
for bk, res_l in dists.items():
print(bk, res_l)
dists[bk] = sum(res_l) / len(res_l) if len(res_l) != 0 else 0
print(dists)
if __name__ == "__main__":
import psutil
if psutil.Process().parent().cmdline()[1:] == sys.argv:
main()
else:
set_env_and_run()