#!/usr/bin/env python3 """job2461-checks.py -- ledger for job #2461. Reads the run log, asserts every recorded number: the published T23 controls (D = 7 952 175, G2 = 204), the observed S2 at p=29 equal to the served [5b] adjacent-pair figure (288), S3 = S4 = 0 at every fold, and the pre-registered decision (observed S2 strictly BELOW the permutation null's 2.5 percentile, i.e. the clustering hypothesis is REFUTED and the anti-clustering sign is measured).""" import re, sys LOG = "job2461-cluster.log" checks = [] def chk(name, cond, detail): checks.append((name, bool(cond), detail)) txt = open(LOG, encoding="utf-8").read() head = re.search(r"W=(\d+) D=(\d+) G2=(\d+)", txt) chk("header parses", head is not None, txt.splitlines()[0] if txt else "empty") W, D, G2 = (int(head.group(1)), int(head.group(2)), int(head.group(3))) chk("D equals published T23 = 7952175", D == 7952175, "D=%d" % D) chk("G2 equals published T23 = 204", G2 == 204, "G2=%d" % G2) chk("W = 2*3*5*...*23 = 223092870", W == 223092870, "W=%d" % W) rows = {} for line in txt.splitlines(): if not line.startswith("fold p="): continue p = int(line.split("p=")[1].split()[0]) def grab(tag): return line.split(tag + "=")[1].split()[0] rows[p] = dict(K=int(grab("K")), S2=int(grab("S2_obs")), S3=int(grab("S3_obs")), S4=int(grab("S4_obs")), mean=float(grab("null mean")), sd=float(grab("sd")), lo=float(grab("q2.5")), hi=float(grab("q97.5")), verdict=line.strip().split("|")[-1].strip()) chk("three folds recorded (29,31,37)", set(rows) == {29, 31, 37}, sorted(rows)) chk("control: S2 at p=29 equals the served [5b] adjacent-pair figure 288", rows.get(29, {}).get("S2") == 288, "S2(29)=%s" % rows.get(29, {}).get("S2")) for p, r in sorted(rows.items()): chk("p=%d has no qualifying run of length >= 3 (S3=0)" % p, r["S3"] == 0, "S3=%d" % r["S3"]) chk("p=%d has no qualifying run of length >= 4 (S4=0)" % p, r["S4"] == 0, "S4=%d" % r["S4"]) chk("p=%d observed S2 strictly BELOW the null 2.5th percentile (anti-clustered)" % p, r["S2"] < r["lo"], "S2=%d < q2.5=%.0f (null mean %.1f)" % (r["S2"], r["lo"], r["mean"])) chk("p=%d ratio null_mean/S2 > 10" % p, r["mean"] / r["S2"] > 10, "%.1fx" % (r["mean"] / r["S2"])) chk("p=%d band does not contain observed (falsifier fired)" % p, not (r["lo"] <= r["S2"] <= r["hi"]), "[%.0f,%.0f]" % (r["lo"], r["hi"])) npass = sum(1 for _, c, _ in checks if c) for name, c, detail in checks: print("%s %s -- %s" % ("PASS" if c else "FAIL", name, detail)) print("\nALL_PASS=%s %d/%d" % (all(c for _, c, _ in checks), npass, len(checks))) sys.exit(0 if all(c for _, c, _ in checks) else 1)