autoresearch-quantum/tests/test_config.py
saymrwulf e13a3268c2 Add teaching notebooks, widget-based quizzes, bug fixes, and expanded tests
- 8 Jupyter notebooks across 3 learning plans (A: bottom-up, B: spiral, C: parallel tracks)
- Teaching toolkit (src/autoresearch_quantum/teaching/) with ipywidgets-based
  quiz, predict_choice, reflect, and order widgets — visually distinct from code cells
- Fix spectator_z operator: was {1:'Z',2:'Z'} (IZZI, expectation=0), now {1:'Z',3:'Z'}
  (ZIZI, expectation=+1 for ideal T-state, commutes with logical operators)
- Fix u_magic seed: swap phase arguments to match h_p and ry_rz preparations
- Fix double-display bug: widgets rendered twice when function returned the box
- Fix CLI override parser for negative integers and missing '=' validation
- Fix stabilizer detection quiz: ZZZZ detects X errors, not Z errors
- Add ties parameter to order() for questions with interchangeable items
- Expand test suite from 21 to 107 tests
- Update README with notebook instructions and project tree
2026-04-07 17:14:37 +02:00

57 lines
1.9 KiB
Python

"""Tests for YAML config loading."""
from __future__ import annotations
from pathlib import Path
from autoresearch_quantum.config import load_rung_config
from autoresearch_quantum.models import ExperimentSpec, RungConfig
def test_load_rung1_config() -> None:
config = load_rung_config(Path("configs/rungs/rung1.yaml"))
assert isinstance(config, RungConfig)
assert config.rung == 1
assert config.name == "[[4,2,2]] Encoded Magic-State Preparation"
assert config.step_budget == 3
assert config.patience == 2
def test_rung1_bootstrap_spec() -> None:
config = load_rung_config(Path("configs/rungs/rung1.yaml"))
spec = config.bootstrap_incumbent
assert isinstance(spec, ExperimentSpec)
assert spec.rung == 1
assert spec.seed_style == "h_p"
assert spec.encoder_style == "cx_chain"
assert spec.target_backend == "fake_brisbane"
def test_rung1_search_space() -> None:
config = load_rung_config(Path("configs/rungs/rung1.yaml"))
dims = config.search_space.dimensions
assert "seed_style" in dims
assert "encoder_style" in dims
assert config.search_space.max_challengers_per_step == 8
def test_rung1_score_config() -> None:
config = load_rung_config(Path("configs/rungs/rung1.yaml"))
assert config.score.name == "weighted_acceptance_cost"
assert config.score.cheap_quality.noisy_fidelity == 0.40
assert config.score.cost_weights.two_qubit_count == 0.08
def test_rung1_tier_policy() -> None:
config = load_rung_config(Path("configs/rungs/rung1.yaml"))
assert config.tier_policy.cheap_shots == 512
assert config.tier_policy.enable_hardware is False
assert config.tier_policy.promote_top_k == 2
def test_load_all_rungs() -> None:
"""All rung configs should load without error."""
for i in range(1, 6):
config_path = Path(f"configs/rungs/rung{i}.yaml")
if config_path.exists():
config = load_rung_config(config_path)
assert config.rung == i