innerloop.py: optimise(root, programme_dir, x0=None, budget, method) -> Result, optimising equal-offset free-branch ratios (midpoint projection of legacy unequal cuts) against full oracle fitness. OracleEvaluator scores each population in one batched perl call. Methods: cma (default) — multi- start sigma ladder (0.05 local, 0.15 exploratory) with IPOP-style popsize doubling and deterministic seeding (pycma treats seed 0 as clock!) — and compass with Hooke-Jeeves pattern moves, kept for the d0s bake-off. Acceptance (experiments/accept_innerloop.py, §4.5 bars vs unprojected originals, within-noise tolerance 1%): x1.65 / x1.66 / x1.58 against bars x1.24 / x1.67 / x1.59, no new failures, 46 oracle calls vs Nelder-Mead's 200. The two near-bar results are statistically indistinguishable from the single-NM-draw bars (measured draw spread brackets them); decision approved by Bruno 2026-06-12. Also: tests/ scaffold (12 oracle-free unit tests, pytest pythonpath=src), rebaseline_no_occlusion.py for homemaker-py-gp2, cma>=3.0 dependency (installed via dnf), dead-variable cleanup in solver.py. Closes homemaker-py-1p0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
31 lines
791 B
Python
31 lines
791 B
Python
"""Oracle unit tests that do not invoke perl."""
|
|
|
|
import pytest
|
|
|
|
from homemaker import oracle
|
|
|
|
|
|
def test_fail_lines_sorted_and_filtered():
|
|
s = oracle.Score(fitness=0.5, fails="---\nb fail\n\na fail\n \n")
|
|
assert s.fail_lines == ("a fail", "b fail")
|
|
assert s.n_fails == 2
|
|
|
|
|
|
def test_fail_lines_empty():
|
|
s = oracle.Score(fitness=0.5, fails="")
|
|
assert s.fail_lines == ()
|
|
assert s.n_fails == 0
|
|
|
|
|
|
def test_score_batch_empty_list():
|
|
assert oracle.score_batch([]) == []
|
|
|
|
|
|
def test_score_batch_rejects_cross_directory(tmp_path):
|
|
a = tmp_path / "a" / "x.dom"
|
|
b = tmp_path / "b" / "y.dom"
|
|
for p in (a, b):
|
|
p.parent.mkdir()
|
|
p.write_text("")
|
|
with pytest.raises(ValueError, match="batch spans directories"):
|
|
oracle.score_batch([a, b])
|