File size: 1,257 Bytes
0a3edb6 | 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 | import glob, sys, collections
import numpy as np, torch
from functional import MACH, C, SRC, SNK, BELTISH, SPLIT, INS, sample, window, thput, E
from measure import CONFIGS
views = sample(sorted(glob.glob(sys.argv[1])), int(sys.argv[2]))
cfg = CONFIGS[sys.argv[3]]
c, ex = collections.Counter(), collections.defaultdict(list)
for i, (r, lab, x0, y0) in enumerate(views):
w, why = window(r, lab, x0, y0, cfg)
if thput(w) > 0:
c["delivers"] += 1; continue
ent = w[C[0]]
n_src, n_snk = int((ent == SRC).sum()), int((ent == SNK).sum())
belts = int(np.isin(ent, list(BELTISH | {SPLIT})).sum())
interior_masked = int((r.inst[x0:x0 + 30, y0:y0 + 30] == -1).mean() * 100)
if belts == 0 and not np.isin(ent, list(MACH | set(INS))).any():
k = "no known flow entities left in the interior"
elif n_src == 0 and n_snk == 0:
k = "no flow crosses the window edge"
elif n_src == 0:
k = "sinks but no source"
elif n_snk == 0:
k = "sources but no sink"
else:
k = "sources and sinks, but nothing connects them"
c[k] += 1; ex[k].append(i)
c[f" (interior >30% masked)"] += interior_masked > 30
for k, v in c.most_common():
print(f"{k:50s} {v:4d} e.g. {ex.get(k, [])[:6]}")
|