Skip to content

Add 3D/embed/perf features#18

Merged
CSSFrancis merged 3 commits into
mainfrom
feat/3d-gpu-embed-perf
Jun 15, 2026
Merged

Add 3D/embed/perf features#18
CSSFrancis merged 3 commits into
mainfrom
feat/3d-gpu-embed-perf

Conversation

@CSSFrancis

Copy link
Copy Markdown
Owner

Major additions across rendering, embedding, and performance:

Rendering & plot types

  • True-colour RGB imshow ((H,W,3|4) arrays)
  • 3D voxels geometry + draggable PlaneWidget slice selectors
  • scatter3d per-point colours, set_highlight, reference sphere, bounds
  • Turntable 3D camera (matplotlib azim/elev; reaches any viewpoint)
  • Mini-TeX label formatting (superscripts/Greek/symbols) + fontsize control
  • IPF and voxel-grain explorer examples; label-formatting example

Embedding (no Jupyter required)

  • anyplotlib.embed: figure_state/to_html/save_html/esm_path + FigureBridge
  • figure_esm.js mount() API for Electron / plain web pages
  • docs/embedding.rst guide

WebGPU (progressive enhancement, canvas fallback)

  • Instanced points + voxels on the GPU via gpu="auto"; airtight Canvas2D fallback (no navigator.gpu / null adapter / device loss). No JS deps.
  • Hardware-verified on NVIDIA Pascal; WEBGPU_PLAN.md tracks phases.

Performance (smoothness under Pyodide)

  • Figure.batch() coalesces panel pushes (one per panel per frame)
  • Geometry channel: heavy buffers ride a separate hash-gated trait, re-sent only on change — view updates (highlight/camera/planes) no longer retransmit geometry. Voxel explorer per-frame traffic -65%.
  • Voxel sprite cache + typed-array projection; RGB imshow skips LUT rebuild

Packaging

  • LICENSE (MIT), wheel excludes tests/baselines, py3.13 classifier
  • RELEASE_PLAN.md; committed uv.lock

Tests: +~90 across labels, embed, RGB, voxels/planes, GPU fallback, batch, geometry channel. Full suite 1323 passed / 58 skipped.

Major additions across rendering, embedding, and performance:

Rendering & plot types
- True-colour RGB imshow ((H,W,3|4) arrays)
- 3D voxels geometry + draggable PlaneWidget slice selectors
- scatter3d per-point colours, set_highlight, reference sphere, bounds
- Turntable 3D camera (matplotlib azim/elev; reaches any viewpoint)
- Mini-TeX label formatting (superscripts/Greek/symbols) + fontsize control
- IPF and voxel-grain explorer examples; label-formatting example

Embedding (no Jupyter required)
- anyplotlib.embed: figure_state/to_html/save_html/esm_path + FigureBridge
- figure_esm.js mount() API for Electron / plain web pages
- docs/embedding.rst guide

WebGPU (progressive enhancement, canvas fallback)
- Instanced points + voxels on the GPU via gpu="auto"; airtight Canvas2D
  fallback (no navigator.gpu / null adapter / device loss). No JS deps.
- Hardware-verified on NVIDIA Pascal; WEBGPU_PLAN.md tracks phases.

Performance (smoothness under Pyodide)
- Figure.batch() coalesces panel pushes (one per panel per frame)
- Geometry channel: heavy buffers ride a separate hash-gated trait, re-sent
  only on change — view updates (highlight/camera/planes) no longer
  retransmit geometry. Voxel explorer per-frame traffic -65%.
- Voxel sprite cache + typed-array projection; RGB imshow skips LUT rebuild

Packaging
- LICENSE (MIT), wheel excludes tests/baselines, py3.13 classifier
- RELEASE_PLAN.md; committed uv.lock

Tests: +~90 across labels, embed, RGB, voxels/planes, GPU fallback,
batch, geometry channel. Full suite 1323 passed / 58 skipped.
@codecov-commenter

codecov-commenter commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.62%. Comparing base (8a9d6fd) to head (e41b905).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
anyplotlib/embed.py 93.61% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
- Coverage   90.84%   90.62%   -0.22%     
==========================================
  Files          31       33       +2     
  Lines        2501     2741     +240     
==========================================
+ Hits         2272     2484     +212     
- Misses        229      257      +28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The default 11px bold 2D title was drawn strip-tight (12px strip, centered),
leaving ~0px top margin.  macOS Chromium hints fonts ~1px taller than the
Windows dev box, so on macOS CI the title ascender reached row 0 of the
title canvas and test_no_clipping flagged it as clipped.

Clamp the drawn title size to padT-4 (reserve ~4px total vertical margin).
Since _padT grows for large/TeX titles, this only affects the 12px default
strip, capping an 11px title to ~8px — a sub-pixel change well within the
visual-regression tolerance (all 24 baselines still match).  Now ~2px top
and bottom margin on the dev box, which absorbs the cross-platform hinting
variance.
Self-review of the geometry channel found two cleanups:

- Figure._push hashed (md5 of a 346 KB json.dumps) the geometry blob on
  EVERY push to detect change — ~1.4 ms of pure CPU per view-only frame
  just to discover nothing changed, partly undercutting the transfer win.
  Replace with a direct equality check against the last-sent geom dict: the
  b64 strings are the same objects when unchanged, so equality short-circuits
  (~0.05 ms/call, 28x faster) and no serialise happens until geometry really
  changes.  Drops the now-unused hashlib import; renames _geom_hash ->
  _geom_last.

- _applyGeom had a dead if/else (both branches identical).  Collapse to a
  single "apply cache when present" with a clearer comment.

No behaviour change; full suite 1323 passed / 58 skipped.
@CSSFrancis CSSFrancis force-pushed the feat/3d-gpu-embed-perf branch from d9c8ef5 to e41b905 Compare June 15, 2026 18:44
@CSSFrancis CSSFrancis merged commit 0ea8633 into main Jun 15, 2026
12 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.

2 participants