Add an animated docs page explaining the section-tracing algorithm - #12
Merged
Merged
Conversation
The walk in `infer_grid_path` is documented only by inline comments, and the example notebooks show traced sections but never the mechanism. Add `docs/source/algorithm.md`, whose centrepiece is an animation stepping through every iteration of a two-segment, eight-step section on a small synthetic grid, plus a static contact sheet of the same eight steps. The overlays make each of the algorithm's three decisions visible: the four neighbours exactly as `build_neighbor_maps` returns them (with walls and the backtrack marked), the admission circle -- centred on the target with radius equal to the current corner's distance, so "admitted" is literally "strictly inside" -- and the two spherical angles whose sum is `deviation`, shaded on the corner that wins. Both angles are drawn, not just the target-side one, because their symmetry is what makes the traced path independent of travel direction. `docs/make_algorithm_animation.py` generates both artifacts. It does not reimplement the walk: it replays `infer_grid_path` to record per-step state for drawing, then asserts that the replayed path equals what `grid_section` returns. A change to the walk therefore makes regeneration fail loudly rather than letting the page drift out of sync with the code. Docs plumbing: enable `myst_parser` so hand-written `.md` pages render, and add `myst-parser` and `ffmpeg` to `docs/environment.yml` -- existing docs environments need rebuilding. Also ignore `docs/source/examples/`, which `conf.py` regenerates (and rmtree's) on every build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of MOM6-community#47 — base is
topology-driven-neighbors, so this diff is docs only.Adds
docs/source/algorithm.md, a page explaining the section-tracing walk ininfer_grid_path. Today that algorithm is documented only by inline comments, and theexample notebooks show traced sections but never the mechanism. The centrepiece is an
animation stepping through every iteration of a two-segment, eight-step section on a small
synthetic grid, plus a static contact sheet of the same eight steps.
What the animation shows
Each iteration plays out in three beats — probe, admit, commit:
build_neighbor_mapsreturns them, with wallsand the backtrack marked.
corner's distance to it, so "admitted" is literally "strictly inside". Every admitted
candidate arcs to both segment endpoints, on equal footing.
deviationshaded at the start and at the target. Both angles are drawn rather than just the
target-side one, because their symmetry is exactly what makes the traced path independent
of travel direction.
The grey background mesh is built from the neighbour maps rather than from index arithmetic,
so it is the graph the walk is actually allowed to move on.
The generator
docs/make_algorithm_animation.pyproduces both artifacts (~0.7 MB combined), committedbecause Read the Docs never executes anything. It does not reimplement the walk: it
replays
infer_grid_pathto record per-step state for drawing, then asserts the replayedpath equals what
grid_sectionreturns. A change to the walk makes regeneration fail loudlyinstead of letting the page drift out of sync.
Things to look at
docs/environment.ymlgainsmyst-parserandffmpeg— existing docsenvironments need rebuilding.
conf.pyenablesmyst_parser; this is the repo's first hand-written.mdpage.docs/source/examples/is now gitignored —conf.pyregenerates andrmtrees it on everybuild, so it was untracked clutter.
docs/source/_static/, which is not excluded fromthe sdist by
pyproject.toml, so they ship to PyPI and stay in history.Checks
pytest— 76 passed, 0 skips.cd docs && make html SPHINXOPTS="-W"— clean, reproducing RTD'sfail_on_warning: true.Video, contact sheet and all four notebook cross-links resolve in the built HTML.
included in this commit: no package code changes here, their sources came back
byte-identical, and the only diff was nondeterministic PNG bytes.
Drafted with AI assistance (Claude Code); the commit carries a
Co-Authored-Bytrailer, perthe project's AI usage policy.
🤖 Generated with Claude Code