Files
ML-Porosity/paper_gp/check_si_refs.py
lamlvh eff975cc96 Address simulated GP referee reports: E1-E6 and A1-A9 (exploratory), theory scope, per-well field and anchor-error tables, scorer v1.1, paper_gp and response letter
Experiments declared and hashed before computing (docs/research/gp-review-*.md). The SMC-mean gain holds against a practitioner tie, all budgets and a same-target point tie, but is lost at anchor errors of 2 ms or less and reverses with per-well bulk error. No locked protocol, verdict or threshold changed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 11:20:54 +00:00

50 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""Check the plain-text Supporting Information references in main.tex against supplement.aux.
Geophysical Prospecting asks for basic LaTeX without cross-document references, so main.tex writes
"Section~S6.1", "Table~S9", ... as text. This script maps each of them to the label it stands for,
reads the numbers that supplement.tex actually produced, and fails if any differ or if main.tex uses
an SI reference that is not in the map. Run after building supplement.tex:
python3 check_si_refs.py
"""
import re
import sys
# text in main.tex -> label in ../paper/sections/
MAP = {
"Section~S2": "sec:related", "Table~S1": "tab:positioning", "Table~S2": "tab:audit",
"Section~S3.2": "sec:data:d2", "Table~S3": "tab:package", "Table~S4": "tab:methods",
"Section~S4.5": "sec:method:rml", "Appendix~SA": "app:proofs", "Appendix~SB": "app:field",
"Appendix~SC": "app:record", "Proposition~S1": "prop:blur", "Proposition~S2": "prop:ident",
"Proposition~S3": "prop:tie", "Proposition~S4": "prop:bank", "Proposition~S6": "prop:reference",
"Corollary~S3": "cor:twomode", "Corollary~S4": "cor:tolerance", "Section~S6.1": "sec:exp:p2",
"Table~S9": "tab:h2a", "Table~S10": "tab:sigmaa", "Section~S6.3": "sec:exp:p2r",
"Section~S6.4": "sec:exp:mech", "Table~S13": "tab:benchdesign", "Table~S14": "tab:benchverdicts",
"Table~S15": "tab:s2", "Table~S17": "tab:t3", "Section~S7": "sec:discussion",
"Table~S19": "tab:lessons", "Corollary~S1": "cor:band", "Proposition~S5": "prop:coverage",
"Lemma~S2": "lem:sandwich",
"Section~SC.5": "app:record:gp", "Table~S7": "tab:h1", "Table~S27": "tab:bandspectra",
}
aux = open("supplement.aux", encoding="utf-8").read()
labels = {m.group(1): m.group(2) for m in re.finditer(r"\\newlabel\{([^}]*)\}\{\{([^}]*)\}", aux)}
text = re.sub(r"(?<!\\)%.*", "", open("main.tex", encoding="utf-8").read())
used = set(re.findall(r"(?:Section|Table|Proposition|Corollary|Appendix|Lemma)~S[0-9A-C]+(?:\.[0-9]+)?", text))
ok = True
for ref in sorted(used - MAP.keys()):
print(f"UNMAPPED {ref}")
ok = False
for ref in sorted(used & MAP.keys()):
want = ref.split("~")[1]
got = labels.get(MAP[ref])
if got is None:
got_s = "missing"
else:
got_s = got if got.startswith("S") else "S" + got
if got_s != want:
print(f"MISMATCH {ref}: label {MAP[ref]} is {got_s}")
ok = False
print(f"{len(used)} SI references checked: {'OK' if ok else 'FAIL'}")
sys.exit(0 if ok else 1)