Exposition To Notebook
Quick start
- Pin down constraints (or assume defaults and add a TODO cell).
- Extract the “computable core” (symbols, inputs/outputs, equations, algorithms).
- Choose a notebook outline and scaffolding approach.
- Build the notebook (
.ipynb) and keep code importable/testable.
- Add validation (sanity checks + minimal tests) and rerun top-to-bottom.
- Polish for handoff (clear narrative, stable outputs, next steps).
Workflow
1) Intake (constraints + deliverables)
Capture:
- Goal: what the notebook should demonstrate/produce.
- Audience: research peer vs. product engineer vs. stakeholder.
- Runtime + environment: CPU/GPU, offline/online, expected Python version.
- Data: provided vs. needs a stub/synthetic generator.
If missing, assume:
- Python 3.10+, CPU-only, no internet, small synthetic data.
- Minimal dependencies (stdlib first; optional
numpy, pandas, matplotlib).
Add a top “Open Questions / TODO” markdown cell if anything is unclear.
2) Decompose the exposition into “things to implement”
Produce (in a markdown cell) a compact inventory:
- Definitions table: symbol → meaning → units/shape/type → notes.
- Assumptions: e.g. independence, boundary conditions, ranges.
- Inputs/outputs: what goes in/out of the core functions.
- Algorithm steps: numbered, with edge cases.
For math: identify which equations must be computed vs. just documented.
3) Notebook design (default section order)
Default section order (adjust to repo conventions):
- Title + TL;DR
- Goal + success criteria
- Setup (deps, versions, seeds)
- Background / exposition (LaTeX + narrative)
- Implementation (small, reusable functions/classes)
- Validation (sanity checks + tests)
- Demo / experiments (plots, tables)
- Conclusion + next steps
- Appendix (derivations, references)
Prefer moving reusable code into a module (e.g. src/ or *_utils.py) and importing it, keeping the notebook focused on orchestration and narrative.
4) Scaffold the .ipynb
- Start from scratch: run
scripts/scaffold_notebook.py --out <path>.ipynb --title "<title>"
- Start from existing Markdown notes: run
scripts/md_to_ipynb.py <notes>.md --out <path>.ipynb --title "<title>" --with-scaffold
5) Implement the computable core
- Convert each computable equation/step into a function with a docstring stating inputs/outputs and assumptions.
- Keep cells idempotent: no hidden state; rerun-from-scratch should match.
- Add small, readable examples next to new functionality.
6) Validate (make it “product-ready”)
Minimum bar:
- Restart kernel + “Run all” completes without errors.
- Deterministic results when possible (seeded randomness).
- At least:
- shape/range/unit sanity checks, and
- a few
assert-style tests for key invariants.
For deeper guidance, see references/product_ready_checklist.md.
Typical outputs
- A single runnable notebook:
notebooks/<slug>.ipynb (or repo-standard location).
- Optional support files when helpful:
src/<module>.py for reusable code
requirements.txt or pyproject.toml snippet for dependencies
- synthetic data generator (so the notebook runs without external data)
1---2name: exposition-to-notebook3description: Convert mathematical derivations, research notes, and textual specs into runnable, product-ready Jupyter notebooks (.ipynb) with clear narrative, LaTeX, modular code, plots, and sanity checks/tests. Use when asked to turn an exposition/paper/spec into a notebook, prototype a method in Jupyter, create a demo notebook, or convert Markdown/LaTeX notes into an executable notebook.4---56# Exposition To Notebook78## Quick start9101. Pin down constraints (or assume defaults and add a TODO cell).112. Extract the “computable core” (symbols, inputs/outputs, equations, algorithms).123. Choose a notebook outline and scaffolding approach.134. Build the notebook (`.ipynb`) and keep code importable/testable.145. Add validation (sanity checks + minimal tests) and rerun top-to-bottom.156. Polish for handoff (clear narrative, stable outputs, next steps).1617## Workflow1819### 1) Intake (constraints + deliverables)2021Capture:22- Goal: what the notebook should demonstrate/produce.23- Audience: research peer vs. product engineer vs. stakeholder.24- Runtime + environment: CPU/GPU, offline/online, expected Python version.25- Data: provided vs. needs a stub/synthetic generator.2627If missing, assume:28- Python 3.10+, CPU-only, no internet, small synthetic data.29- Minimal dependencies (stdlib first; optional `numpy`, `pandas`, `matplotlib`).3031Add a top “Open Questions / TODO” markdown cell if anything is unclear.3233### 2) Decompose the exposition into “things to implement”3435Produce (in a markdown cell) a compact inventory:36- **Definitions table**: symbol → meaning → units/shape/type → notes.37- **Assumptions**: e.g. independence, boundary conditions, ranges.38- **Inputs/outputs**: what goes in/out of the core functions.39- **Algorithm steps**: numbered, with edge cases.4041For math: identify which equations must be computed vs. just documented.4243### 3) Notebook design (default section order)4445Default section order (adjust to repo conventions):461. Title + TL;DR472. Goal + success criteria483. Setup (deps, versions, seeds)494. Background / exposition (LaTeX + narrative)505. Implementation (small, reusable functions/classes)516. Validation (sanity checks + tests)527. Demo / experiments (plots, tables)538. Conclusion + next steps549. Appendix (derivations, references)5556Prefer moving reusable code into a module (e.g. `src/` or `*_utils.py`) and importing it, keeping the notebook focused on orchestration and narrative.5758### 4) Scaffold the `.ipynb`5960- Start from scratch: run `scripts/scaffold_notebook.py --out <path>.ipynb --title "<title>"`61- Start from existing Markdown notes: run `scripts/md_to_ipynb.py <notes>.md --out <path>.ipynb --title "<title>" --with-scaffold`6263### 5) Implement the computable core6465- Convert each computable equation/step into a function with a docstring stating inputs/outputs and assumptions.66- Keep cells idempotent: no hidden state; rerun-from-scratch should match.67- Add small, readable examples next to new functionality.6869### 6) Validate (make it “product-ready”)7071Minimum bar:72- Restart kernel + “Run all” completes without errors.73- Deterministic results when possible (seeded randomness).74- At least:75 - shape/range/unit sanity checks, and76 - a few `assert`-style tests for key invariants.7778For deeper guidance, see `references/product_ready_checklist.md`.7980## Typical outputs8182- A single runnable notebook: `notebooks/<slug>.ipynb` (or repo-standard location).83- Optional support files when helpful:84 - `src/<module>.py` for reusable code85 - `requirements.txt` or `pyproject.toml` snippet for dependencies86 - synthetic data generator (so the notebook runs without external data)