Skip to content

Add an animated docs page explaining the section-tracing algorithm - #12

Merged
hdrake merged 1 commit into
topology-driven-neighborsfrom
algorithm-walkthrough-docs
Aug 10, 2026
Merged

Add an animated docs page explaining the section-tracing algorithm#12
hdrake merged 1 commit into
topology-driven-neighborsfrom
algorithm-walkthrough-docs

Conversation

@hdrake

@hdrake hdrake commented Aug 10, 2026

Copy link
Copy Markdown
Owner

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 in
infer_grid_path. Today that algorithm is documented only by inline comments, and the
example 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:

  • probe — the four neighbours exactly as build_neighbor_maps returns them, with walls
    and the backtrack marked.
  • admit — the admission circle, centred on the target with radius equal to the current
    corner's distance to it, so "admitted" is literally "strictly inside". Every admitted
    candidate arcs to both segment endpoints, on equal footing.
  • commit — the winner in orange, with the two spherical angles whose sum is deviation
    shaded 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.py produces both artifacts (~0.7 MB combined), committed
because Read the Docs never executes anything. It does not reimplement the walk: it
replays infer_grid_path to record per-step state for drawing, then asserts the replayed
path equals what grid_section returns. A change to the walk makes regeneration fail loudly
instead of letting the page drift out of sync.

Things to look at

  • docs/environment.yml gains myst-parser and ffmpeg — existing docs
    environments need rebuilding.
  • conf.py enables myst_parser; this is the repo's first hand-written .md page.
  • docs/source/examples/ is now gitignored — conf.py regenerates and rmtrees it on every
    build, so it was untracked clutter.
  • The two binary artifacts live under docs/source/_static/, which is not excluded from
    the 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's fail_on_warning: true.
    Video, contact sheet and all four notebook cross-links resolve in the built HTML.
  • The page's runnable snippet was executed and its pasted output captured from the real run.
  • All five example notebooks were re-executed cleanly against this branch. They are not
    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-By trailer, per
the project's AI usage policy.

🤖 Generated with Claude Code

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>

@hdrake hdrake left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Looks great!

@hdrake
hdrake merged commit fe35ddc into topology-driven-neighbors Aug 10, 2026
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.

1 participant