Skip to content

feat: observer-based recording and stable animation for the canonicalizer#217

Closed
GrovyleX wants to merge 1 commit into
QPauLie:mainfrom
GrovyleX:feat/canonicalizer-animation
Closed

feat: observer-based recording and stable animation for the canonicalizer#217
GrovyleX wants to merge 1 commit into
QPauLie:mainfrom
GrovyleX:feat/canonicalizer-animation

Conversation

@GrovyleX

Copy link
Copy Markdown

Closes #199. An alternative implementation of the graph-transformation animation (see also #207).

Reintroduces the animation feature by wrapping the current Canonicalizer with an observer
(as suggested in the issue), so the recorder only watches and never changes the algorithm.

Demo

Smooth on a long leg (algebra a17, n=10). Positions and distances stay fixed as the graph
grows; a vertex moves only when the algorithm actually restructures its leg:

a17_n10

A-type 4*so(5) and B-type sp(4) worked examples:

example_c example_d

What's included

  • Recording layer (helpers/_recording.py): RecordGraph / FrameRecord / FrameGraph /
    recording_graph, capturing every event (lighting, contraction, attach, p/q, removals,
    replacements, dependents, leg manipulation).
  • Observer (classifier/observer.py): typed CanonicalizerEvent enum + EventManager.
    The base Canonicalizer emits guarded notifications and is a no-op when nothing subscribes,
    so behaviour and all existing tests are unchanged.
  • RecordingCanonicalizer (classifier/recording_canonicalizer.py): drop-in subclass,
    mirrors the existing TrackedCanonicalizer idiom; a recorded run classifies identically to
    a plain one.
  • Renderer (helpers/drawing.py): per-role colours, an interactive to_jshtml player
    (play / pause / step / slider), and a stable incremental layout.
  • Docs: restored A-type and B-type walkthroughs in classification.rst with embedded
    players and a swatch colour legend. Animations are generated at build time by conf.py, so
    no media is committed. docs/generate_animations.py regenerates them locally.

Notes on the review feedback raised so far

  • Smooth, no-jump animation: the layout is persistent and incremental. A vertex keeps its
    position, spacing is constant, long legs fold into rows, and the viewport is frozen. On
    a17, n=10 (51 frames) only 8 frames have any motion, each a genuine restructure, ending in
    a clean star.
  • Algebra in the terminal title: e.g. Canonical graph of type B3: su(1024).
  • Distinguishable swatch legend: reuses the existing .color-legend / .swatch CSS.
  • Interactive control bar: to_jshtml(default_mode="loop").
  • Commented geometry: the new layout is documented block by block.
  • Rebased on current main (post low-rank-isomorphism); classification.py is untouched.

Testing

  • New tests/test_recording.py: frame invariants, layout stability (growth / relabel / fold),
    and recorded-vs-plain algebra equality across all G_LIE two-local algebras.
  • Full suite: 966 passing. ruff, pylint (10/10), mypy src/paulie/application, and
    sphinx-build -W all green.

…izer

Closes QPauLie#199. Wrap the current Canonicalizer with an observer that records each
transformation step; render an interactive, jump-free animation.
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.

Animations of Graph Transformation

2 participants