interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / scripts / allen / science / evidence / run_hard20.py

26 lines · 1409 bytes Raw Blame History
1#!/usr/bin/env python3
2# Run hard20.jsonl against an aien-math binary and judge each row with the corpus's own
3# tests/oracle_common.verdict (no second matcher). Usage: run_hard20.py ENGINE_ROOT [BIN]
4import json, os, subprocess, sys
5root = sys.argv[1]
6binp = sys.argv[2] if len(sys.argv) > 2 else os.path.join(root, "build", "aien-math")
7sys.path.insert(0, os.path.join(root, "tests"))
8from oracle_common import load, verdict, expected # noqa: E402
9here = os.path.dirname(os.path.abspath(__file__))
10cases = load(os.path.join(here, "hard20.jsonl"))
11out, tally = [], {}
12for c in cases:
13 try:
14 p = subprocess.run([binp, "eval", "-e", c["code"]], capture_output=True, text=True, timeout=60)
15 got, rc = p.stdout.rstrip("\n"), p.returncode
16 except subprocess.TimeoutExpired:
17 got, rc = "<timeout>", -1
18 v = verdict(c, got, rc)
19 tally[v] = tally.get(v, 0) + 1
20 out.append({"id": c["id"], "topic": c["topic"], "code": c["code"], "want": expected(c),
21 "compare": c.get("compare", "exact"), "source": c["source"],
22 "oracle_row": c["oracle_row"], "observed": got, "rc": rc, "verdict": v})
23 print(f"{c['id']:3s} {v:12s} rc={rc} {c['code'][:70]}")
24json.dump({"binary": binp, "results": out, "tally": tally}, open(os.path.join(here, "hard20-results.json"), "w"), indent=1)
25print("tally", tally)
26sys.exit(0 if tally.get("pass", 0) == len(cases) else 1)