text
stringlengths
0
262
def test_diatomic_configs_match_independent_recompute():
LOGS.mkdir(parents=True, exist_ok=True)
inst = load_instance()
const = inst["constants"]
di_cfgs = inst.get("diatomic_configs", [])
assert len(di_cfgs) >= 1, "expected at least one diatomic supercell config"
by_id = load_diatomic_results()
ids_expected = {e["id"] for e in di_cfgs}
assert set(by_id) >= ids_expected, f"results.json missing diatomic configs: {ids_expected - set(by_id)}"
summary = []
for entry in di_cfgs:
rec = by_id[entry["id"]]
ref = ref_solve_di(di_pkey_for(entry, const))
> grade_config_di(rec, ref, f"diatomic {entry['id']}")
/verifier/test_outputs.py:988:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/verifier/test_outputs.py:792: in grade_config_di
grade_scalar(rec, ref, "gap_decay_geom", 0.10, 0.02, where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rec = {'N': 12, 'attn_geom_max': 0.22239704590688977, 'f_H_A': 371.6252902397012, 'f_H_B': 506.4682746566647, ...}
ref = {'attn_geom_max': 0.22239704157792842, 'f_H_A': 371.6252902397011, 'f_H_B': 506.4682746566645, 'gap_decay_geom': 0.20537903283883774, ...}
key = 'gap_decay_geom', rel = 0.1, ab = 0.02
where = 'diatomic diatomic_supercell'
def grade_scalar(rec, ref, key, rel, ab, where):
assert key in rec and rec[key] is not None, f"{where}: missing '{key}'"
> assert approx(rec[key], ref[key], rel, ab), (
f"{where}: {key}={rec[key]} vs reference {ref[key]} (rel={rel}, abs={ab})")
E AssertionError: diatomic diatomic_supercell: gap_decay_geom=-0.20500975653824755 vs reference 0.20537903283883774 (rel=0.1, abs=0.02)
E assert False
E + where False = approx(-0.20500975653824755, 0.20537903283883774, 0.1, 0.02)
/verifier/test_outputs.py:596: AssertionError
__________________ test_diatomic_held_out_solver_generalises ___________________
def test_diatomic_held_out_solver_generalises():
"""Run the agent's own diatomic solver on hidden two-resonator geometries and
grade against the independent recompute. A monatomic or memorised solver fails."""
assert SOLVER_DI.is_file(), "Missing diatomic solver"
LOGS.mkdir(parents=True, exist_ok=True)
inst = load_instance()
const = inst["constants"]
records = []
for label, spec in HIDDEN_DI_SPECS:
p = dict(c=const["c"], rho=const["rho"], r_d=const["r_d"], **spec)
cmd = [sys.executable, str(SOLVER_DI),
"--r_nA", repr(p["r_nA"]), "--l_nA", repr(p["l_nA"]), "--VA", repr(p["VA"]),
"--r_nB", repr(p["r_nB"]), "--l_nB", repr(p["l_nB"]), "--VB", repr(p["VB"]),
"--d", repr(p["d"]), "--N", str(p["N"]),
"--r_d", repr(p["r_d"]), "--c", repr(p["c"]), "--rho", repr(p["rho"])]
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
assert proc.returncode == 0, (
f"held-out {label}: diatomic solver failed: {proc.stderr[-800:]}")
payload = None
for line in reversed(proc.stdout.strip().splitlines()):
line = line.strip()
if line.startswith("{"):
payload = json.loads(line)
break
assert payload is not None, f"held-out {label}: diatomic solver produced no JSON"
ref = ref_solve_di(tuple(sorted(p.items())))
> grade_config_di(payload, ref, f"HELD-OUT DIATOMIC {label}")
/verifier/test_outputs.py:1035:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/verifier/test_outputs.py:792: in grade_config_di
grade_scalar(rec, ref, "gap_decay_geom", 0.10, 0.02, where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rec = {'N': 12, 'attn_geom_max': 0.2839631181985518, 'f_H_A': 357.8675462351419, 'f_H_B': 456.88620357338476, ...}
ref = {'attn_geom_max': 0.28396311725642365, 'f_H_A': 357.8675462351419, 'f_H_B': 456.8862035733847, 'gap_decay_geom': 0.2738032617052612, ...}
key = 'gap_decay_geom', rel = 0.1, ab = 0.02
where = 'HELD-OUT DIATOMIC holdout_di_a'
def grade_scalar(rec, ref, key, rel, ab, where):
assert key in rec and rec[key] is not None, f"{where}: missing '{key}'"
> assert approx(rec[key], ref[key], rel, ab), (
f"{where}: {key}={rec[key]} vs reference {ref[key]} (rel={rel}, abs={ab})")
E AssertionError: HELD-OUT DIATOMIC holdout_di_a: gap_decay_geom=-0.2729765594672979 vs reference 0.2738032617052612 (rel=0.1, abs=0.02)
E assert False
E + where False = approx(-0.2729765594672979, 0.2738032617052612, 0.1, 0.02)
/verifier/test_outputs.py:596: AssertionError
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ::test_frozen_instance_untampered
PASSED ::test_results_present_and_complete
PASSED ::test_solver_is_a_real_computation
PASSED ::test_reciprocity_and_energy_invariants
PASSED ::test_hybridisation_widens_the_gap
PASSED ::test_ratio_ordering_across_configs
PASSED ::test_effective_index_follows_compliance_law
PASSED ::test_diatomic_solver_is_a_real_computation
PASSED ::test_diatomic_reciprocity_and_energy
PASSED ::test_no_leaked_reference_artifacts
FAILED ::test_each_config_matches_independent_recompute - AssertionError: con...
FAILED ::test_held_out_solver_generalises - AssertionError: HELD-OUT holdout_...
FAILED ::test_diatomic_configs_match_independent_recompute - AssertionError: ...