-
Notifications
You must be signed in to change notification settings - Fork 11
/
compare.py
executable file
·102 lines (78 loc) · 2.2 KB
/
compare.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python
import sys
from collections import Counter, defaultdict
from dump import dump
from report import load_predictions
from utils import choose_predictions, is_plausible
dnames = sys.argv[1:]
all_preds = dict()
all_insts = set()
for dname in dnames:
dump(dname)
preds = load_predictions([dname], devin_only=True)
all_preds[dname] = preds
dump(sum(pred["resolved"] for pred in preds.values()))
all_insts.update(preds.keys())
chosen = choose_predictions(dnames, devin_only=True)
histories = dict()
resolved = defaultdict(int)
for inst in all_insts:
history = []
for dname in dnames:
pred = all_preds[dname].get(inst)
if pred is None:
history += ["n/a", "n/a"]
continue
if is_plausible(pred):
history += ["plausible"]
else:
history += ["no"]
if pred["resolved"]:
history += ["resolved"]
else:
history += ["no"]
if history == ["non-plausible", "not resolved", "n/a", "n/a"]:
dump(inst)
history = [f"{x:10}" for x in history]
history = " | ".join(history)
histories[inst] = history
if chosen[inst]["resolved"]:
resolved[history] += 1
odd = []
for inst in odd:
history = histories[inst]
dump(history, inst)
histories = dict((inst, kind) for inst, kind in histories.items())
counts = Counter(histories.values())
counts = sorted(counts.items(), reverse=True)
row = 0
total = 0
for history, cnt in counts:
label = chr(ord("A") + row)
row += 1
total += cnt
print(f"| {label} | {history} | {cnt:3} | {resolved[history]:3d} |")
dump(total)
dump(sum(resolved.values()))
sys.exit()
dump(len(all_insts))
resolvers = []
for inst in all_insts:
who_resolved = tuple(
sorted(
dname
for dname, preds in all_preds.items()
if preds.get(inst, dict()).get("resolved", False)
)
)
resolvers.append(who_resolved)
# if len(who_resolved) == 1:
# pred = all_preds[dname][inst]
# # dump(pred)
total_resolved = 0
counts = Counter(resolvers)
for who, cnt in counts.items():
dump(who, cnt)
if who:
total_resolved += cnt
dump(total_resolved)