Skip to content

plot_network caption, reserved legend rows, x264 preset (0.2.0) - #191

Merged
jeremymanning merged 7 commits into
mainfrom
feature/network-plot-gaps
Nov 23, 2026
Merged

jeremymanning merged 7 commits into
mainfrom
feature/network-plot-gaps

Conversation

@jeremymanning

Copy link
Copy Markdown
Member

Three options for the 0.2.0 network plots and animations, found while a downstream tutorial was ported to the 0.2.0 API (follow-up to #188 / #189).

What changes

Option What the code does
plot_network(..., caption=None) One line of text, drawn by the same code that draws an animate_network frame's caption: under the view titles with views, legend or frame_size; in a band above the image otherwise.
Empty legend row legend=[[], row] or legend=[row, []] reserves one blank band of the normal row height in that position, in plot_network and animate_network. legend=[] still raises.
preset=None On write_animation and animate_network: the x264 -preset name (ultrafast ... placebo). An unknown name raises ValueError; GIF output raises, as crf does.

HTFAResults.plot_network forwards caption. The changelog's 0.2.0 section, the design spec, and tutorials 10 and 11 describe the three options.

Behavior of existing calls

Calls that pass none of the three arguments are unchanged: 6 edge-free stills and the frames and mp4 bytes of 2 captioned movies are identical to 56cb1a1 (14 of 14 files). preset=None gives byte-identical files. The GIF error messages for crf and faststart keep their text when no preset is given.

A still with caption= equals a one-window movie frame with the same caption when both crop boxes match (always without views, legend or frame_size); with those arguments a still's crop comes from the nodes as drawn and a movie's from opaque nodes at their largest radius, so the framing can differ.

One existing test changed

test_legend_validation expected legend=[[]] to raise; with the empty-row rule it is valid. The other invalid cases stay, and a row mixed with a bare entry was added.

Checks

  • macOS, Python 3.12: make lint clean; make test 1227 passed, 19 skipped (before the review fixes); after them tests/test_brainnet.py, tests/test_headless.py, tests/test_docs.py 185 passed, 5 skipped; make docs 0 warnings.
  • Ubuntu 26.04 container (Mesa 26.0.8, Python 3.13): plotting, headless, docs and package tests 183 passed, 8 skipped.
  • Python 3.10: the caption, legend, preset, crf and GIF tests 25 passed.
  • Not run locally: Windows. The preset tests read x264's settings string from the encoded file; that it is present was confirmed on macOS and Linux only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G

jeremymanning and others added 7 commits November 22, 2026 20:57
…raws a frame's caption

plot_network now finishes its image with _finish_frame, the function that
finishes each animate_network frame, so caption=text gives the frame of a
one-window movie with captions=[text]: a _with_header band without views,
legend and frame_size, else a line under the view titles. caption=None
renders as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G
legend=[[], row] or [row, []] leaves a band of the normal row height in
the background color where the empty row is, in plot_network and
animate_network; a legend of empty rows only reserves its bands. legend=[]
still raises ValueError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G
…mate_network

preset is one of x264's ten preset names, else ValueError naming the value
and the allowed names; with a GIF it raises ValueError as crf and faststart
do. preset=None passes no -preset, so the encoding is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G
Changelog 0.2.0 items and design-spec paragraphs for the three additions;
tutorial 11 shows a captioned still with legend=[[], row], tutorial 10's
re-encoding cell adds crf=28 with preset="slow" (sizes now in three
decimals). Both notebooks re-executed; no asset's code changed, so the
committed assets are kept. Docstrings say slower presets usually give
smaller files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G
…errors, caption claims

- An empty legend row's band is cleared to the background after the views
  are drawn, so it no longer holds the end of the divider between views;
  frames without empty rows are pixel-identical.
- For a GIF, crf or faststart without preset raise the error message of
  56cb1a1; preset is named only when one was given.
- plot_network's caption docstring no longer says the still always equals a
  one-window movie frame: the caption is drawn by the same code, and the
  images are equal where both crops are the same.
- Tests assert the whole blank band, pin the old GIF messages, and check
  the caption of a titled, fixed-size still on its own (dark text under the
  titles; panes lower and, in a height-limited frame, shorter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G
…y precisely

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcKtyt2ULJKvi7Z1bbZU4G
@jeremymanning
jeremymanning merged commit 3ff4821 into main Nov 23, 2026
34 checks passed
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