beyarkay's picture
Lane re-export scripts and progress, window debugging scripts
0a3edb6 verified
Raw History Blame Contribute Delete
812 Bytes
import glob, itertools, sys, time
import numpy as np
import corpus.convert as cv
from build_tasks import records
n, tr, counts = 30, 0.0, {15: [], 30: []}
for rec in itertools.islice((r for r in records(sorted(glob.glob(sys.argv[1]))) if r.get("lanes")), 300):
bp = next(cv.designs(rec["string"])); bp["unbuildable"] = rec["unbuildable"]; bp["lanes"] = rec["lanes"]
t = time.time(); r = cv.rasterise(bp); tr += time.time() - t
if r is None: continue
W, H = r.ent.shape
for s in counts:
counts[s].append(sum(cv.cut(r, (slice(x, x + n), slice(y, y + n))) is not None for x in range(1, W - n, s) for y in range(1, H - n, s)))
print(f"rasterise {tr / 300 * 1000:.0f} ms")
for s, c in counts.items(): print(s, "mean", np.mean(c), "median", np.median(c), "zero", np.mean(np.array(c) == 0))