"""Revision point 3: the diagnosis scripts that verify_article.py runs score a run by the paper's single criterion (a sign change within 1e-6 or f(x) == 0), and the audit of the similarity places reads the re-scored sweeps. Exact anchors, counted, or nothing is written. python -u apply_diag_uniform.py """ from __future__ import annotations EDITS = { "diag_model_order.py": [ (" if c and math.isfinite(float(x)) and abs(float(x) - r) <= ACC:", " if c and solved(f, float(x)):", 1), (" if not (conv and abs(float(x) - r) <= ACC):", " if not (conv and solved(f, float(x))):", 1), ("XTOL, MAXFEV, ACC = 1e-12, 200, 1e-6", "XTOL, MAXFEV, ACC = 1e-12, 200, 1e-6\n" "# success = the paper's single criterion since 2026-09-22 (revision point 3)\n" "from corpus_roots_jl import solved # noqa: E402", 1), ], "diag_model_order_checks.py": [ (" if not (conv and abs(float(x) - r) <= ACC):", " if not (conv and solved(f, float(x))):", 1), ("from diag_model_order import ACC, MAXFEV, OURS, XTOL, ch_cost, iqi", "from diag_model_order import ACC, MAXFEV, OURS, XTOL, ch_cost, iqi, solved", 1), ], "diag_flat_detectable.py": [ (" if not (conv and abs(float(x) - r) <= ACC):", " if not (conv and solved(f, float(x))):", 1), ("from diag_model_order import ACC, MAXFEV, OURS, XTOL", "from diag_model_order import ACC, MAXFEV, OURS, XTOL, solved", 1), ], "audit_similarity_places.py": [ ("def load(path):\n with open(path, encoding=\"utf8\") as fh:\n return json.load(fh)\n", "def load(path):\n \"\"\"The sweep re-scored under the paper's single criterion (sweep_uniform.json).\"\"\"\n" " from rescore_uniform import load_uniform\n return load_uniform(path)\n", 1), ], } new = {} for path, edits in EDITS.items(): src = open(path, encoding="utf8").read() for old, rep, count in edits: assert src.count(old) == count, (path, old[:60], src.count(old)) src = src.replace(old, rep) new[path] = src for path, src in new.items(): open(path, "w", encoding="utf8").write(src) print("edited", ", ".join(new))