Skip to content

docs: add marimo notebooks to the companion book - #15

Merged
tschm merged 5 commits into
mainfrom
docs/marimo-notebooks
Jul 4, 2026
Merged

docs: add marimo notebooks to the companion book#15
tschm merged 5 commits into
mainfrom
docs/marimo-notebooks

Conversation

@tschm

@tschm tschm commented Jul 3, 2026

Copy link
Copy Markdown
Member

What

Three self-contained marimo notebooks under book/marimo/notebooks/, wired into the companion book (exported to docs/notebooks/*.html by make book and linked from a new Notebooks nav section). Layout follows the jebel-quant/jquantstats convention.

notebook covers
01 — Active-set methods The active-set / block-principal-pivoting loop for min_{x≥0} ½x'Ax − b'x: KKT/LCP conditions, the reduced free-set solve, the primal/dual violator tests, and the least-index Bland fallback that guarantees finite termination. Interactive solve with a free-set trajectory heatmap.
02 — Equality constraints solve_nnqp vs solve_nnqp_eq: the multiplier λ, the saddle system, the p×p Schur complement, the shifted reduced gradient s = Ax − b − Bᵀλ, and the p=1 simplex/budget case with a live slider.
03 — Test problems Documents tests/problems.py: the plant-a-known-optimum recipe, make_problem, make_eq_problem, make_adversarial (forces the fallback — 19/40 seeds), and make_scaled_problem (CG vs Jacobi-PCG).

How it hooks into the build

  • Each notebook carries a PEP 723 header with [tool.uv.sources] nncg = { path = "../../..", editable = true }, so the synced _book-notebooks target (marimo export html --sandbox) resolves the local package. Notebook 03 locates the repo root at runtime so its tests.problems import works under the sandbox cwd.
  • marimo>=0.18.0 added to the dev dependency group (which is in default-groups) so uv run marimo resolves — the empty dev group would otherwise break make book.
  • mkdocs.yml: new Notebooks nav section.

Verification

  • make book builds end-to-end; all three notebooks export and appear in _book/notebooks/ and the nav.
  • All three execute cleanly under marimo export html --sandbox (the exact book path).
  • ruff check and ruff format --check pass; full pre-commit hook suite green.

🤖 Generated with Claude Code

Three self-contained marimo notebooks under book/marimo/notebooks/, exported
to docs/notebooks/*.html by `make book` and linked from a new Notebooks nav
section, following the jquantstats layout:

- 01_active_set_methods: the active-set / block-principal-pivoting loop for
  min_{x>=0} 1/2 x'Ax - b'x — KKT/LCP conditions, the reduced free-set solve,
  the primal/dual violator tests, and the least-index Bland fallback that
  guarantees finite termination. Interactive solve with a free-set trajectory.
- 02_equality_constraints: solve_nnqp vs solve_nnqp_eq — the multiplier, the
  saddle system, the p-by-p Schur complement, the shifted reduced gradient,
  and the p=1 simplex/budget case.
- 03_test_problems: documents tests/problems.py — the plant-a-known-optimum
  recipe, make_problem, make_eq_problem, make_adversarial (forces the
  fallback), and make_scaled_problem (CG vs Jacobi-PCG).

Each notebook carries a PEP 723 header with a local editable nncg source so
`marimo export html --sandbox` resolves the package. marimo is added to the
dev dependency group so `uv run marimo` in the synced _book-notebooks target
resolves.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 3, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds three self-contained Marimo notebooks to the project’s companion MkDocs book, including wiring them into the site navigation and ensuring the book build can export the notebooks to standalone HTML.

Changes:

  • Add marimo>=0.18.0 to the dev dependency group (and lockfile) so the book’s notebook export tooling resolves.
  • Add a new Notebooks section to mkdocs.yml that links the exported HTML pages.
  • Introduce three new Marimo notebook scripts under book/marimo/notebooks/.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
uv.lock Locks marimo and its transitive dependencies; updates dev metadata to include the dev group.
pyproject.toml Adds marimo>=0.18.0 to the dev dependency group used by the book build.
mkdocs.yml Adds a Notebooks nav section linking to exported HTML notebook artifacts.
book/marimo/notebooks/01_active_set_methods.py New Marimo notebook documenting the active-set/BPP/Bland fallback path.
book/marimo/notebooks/02_equality_constraints.py New Marimo notebook documenting the equality-constraint (Schur complement) solver path.
book/marimo/notebooks/03_test_problems.py New Marimo notebook documenting/using test problem generators and solver behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread book/marimo/notebooks/01_active_set_methods.py Outdated
Comment thread book/marimo/notebooks/02_equality_constraints.py Outdated
Comment thread book/marimo/notebooks/03_test_problems.py Outdated
Comment on lines +70 to +76
_here = Path.cwd()
for _cand in (_here, *_here.parents):
if (_cand / "tests" / "problems.py").exists():
if str(_cand) not in sys.path:
sys.path.insert(0, str(_cand))
break

tschm and others added 4 commits July 3, 2026 23:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…b dev dep

Drop the sys.path hack and `from tests.problems import ...` in
03_test_problems.py — the four generators are now inlined verbatim so the
notebook is self-contained (clears deptry DEP001 'tests'). Add matplotlib to
the dev dependency group so the notebooks' plotting import is declared
(clears DEP001 'matplotlib' across all three notebooks).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tschm
tschm merged commit f0b13e9 into main Jul 4, 2026
55 checks passed
@tschm
tschm deleted the docs/marimo-notebooks branch July 4, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants