autoresearch-quantum/scripts/strip_teaching_cells.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

53 lines
1.5 KiB
Python

"""Remove all teaching-injected cells from notebooks, restoring original content."""
import json
from pathlib import Path
NOTEBOOKS = [
"notebooks/plan_a/01_encoded_magic_state.ipynb",
"notebooks/plan_a/02_measuring_progress.ipynb",
"notebooks/plan_a/03_the_ratchet.ipynb",
"notebooks/plan_b/spiral_notebook.ipynb",
"notebooks/plan_c/00_dashboard.ipynb",
"notebooks/plan_c/track_a_physics.ipynb",
"notebooks/plan_c/track_b_engineering.ipynb",
"notebooks/plan_c/track_c_search.ipynb",
]
TEACHING_MARKERS = [
"LearningTracker",
"tracker.set_section",
"multiple_choice(",
"predict(",
"check_prediction(",
"numerical_answer(",
"free_response(",
"code_challenge(",
"concept_sort(",
"checkpoint_summary(",
"tracker.dashboard()",
"tracker.save()",
"## Final Assessment",
"Check your understanding",
"Prediction",
"Exploration Guide",
"Learning Dashboard",
]
for nb_path_str in NOTEBOOKS:
nb_path = Path(nb_path_str)
if not nb_path.exists():
continue
nb = json.loads(nb_path.read_text())
original_count = len(nb["cells"])
kept = []
for cell in nb["cells"]:
src = "".join(cell.get("source", []))
is_teaching = any(marker in src for marker in TEACHING_MARKERS)
if not is_teaching:
kept.append(cell)
nb["cells"] = kept
nb_path.write_text(json.dumps(nb, indent=1, ensure_ascii=False))
print(f"{nb_path}: {original_count} -> {len(kept)} cells")