Skip to content

Commit 5f2ae2b

Browse files
committed
test(recovery): bind m01 new-era surface test by id, not __FREE (ADR-0034 fallout)
test_de_recovers_via_experiment_surface drove the new-era experiment:/data: surface with the legacy spec.free `{'k__FREE': ...}` against the `k k__FREE` alias model. Once ADR-0034 made the new-era surface bind free parameters BY ID (no __FREE marker), the config loader correctly rejected `k__FREE` (the model's parameter ids are S_init, k), so this recovery test failed on main — caught only now because the recovery tier is opt-in (-m recovery) and was not run when ADR-0034 landed. Fix is local to this one test (the legacy make_config tests still exercise the __FREE alias): rewrite the new-era model's `k k__FREE` alias to a bare `k <nominal>` and declare the free parameter by its bare id `k`. The shared data-generation path (exp_for / simulate_truth) is unchanged. Full `-m recovery` tier now green (16 passed).
1 parent 06d2132 commit 5f2ae2b

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

tests/test_recovery.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
Needs bngsim (auto-skipped via the ``bngsim`` marker) and BNG2.pl for the
3333
one-time network generation (``recovery_harness.require_bng2pl`` skips otherwise).
3434
"""
35-
from dataclasses import dataclass
35+
import re
36+
from dataclasses import dataclass, replace
37+
from pathlib import Path
3638

3739
import numpy as np
3840
import pytest
@@ -238,9 +240,19 @@ def test_de_recovers_via_experiment_surface(seed, tmp_path, exp_for):
238240
"""
239241
spec = MODELS['m01_exp_decay']
240242
exp_path = exp_for(spec.name) # zero-noise oracle (generated via the original model)
243+
# New-era binds free parameters BY ID (ADR-0034): drop the legacy `k k__FREE` alias for
244+
# a bare `k <nominal>` and declare the free parameter by its bare id `k` (the
245+
# make_config tests above still exercise the legacy __FREE alias). The nominal is
246+
# irrelevant to the fit (lh initialization samples from the bounds).
241247
newera_model = H.strip_actions_block(spec.path, tmp_path / 'm01_newera.bngl')
242-
conf = H.make_newera_config(tmp_path, newera_model, exp_path, spec.free, 'decay', 'de',
243-
random_seed=seed, refine=1, **spec.de_budget)
248+
text = re.sub(r'(?m)^(\s*k\s+)k__FREE\b', r'\g<1>1.0',
249+
Path(newera_model).read_text())
250+
Path(newera_model).write_text(text)
251+
newera_spec = replace(spec, free={'k': ('uniform_var', 1e-3, 5.0)},
252+
true={'k': spec.true['k__FREE']}, identifiable=('k',))
253+
conf = H.make_newera_config(tmp_path, newera_model, exp_path, newera_spec.free,
254+
'decay', 'de', random_seed=seed, refine=1,
255+
**spec.de_budget)
244256

245257
# The simulation is synthesized from the data: the BNGL action carries sample_times
246258
# (the data's time points), and the data binds under the experiment name.
@@ -258,7 +270,7 @@ def test_de_recovers_via_experiment_surface(seed, tmp_path, exp_for):
258270
bound = spec.hard_rel_tol * _data_ss(cols, arr, spec.obs)
259271
assert alg.trajectory.best_score() < bound, \
260272
'%s (new-era): best objective %g not < %g' % (spec.name, alg.trajectory.best_score(), bound)
261-
_assert_recovered(spec, alg)
273+
_assert_recovered(newera_spec, alg)
262274

263275

264276
# --------------------------------------------------------------------------- #

0 commit comments

Comments
 (0)