You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
viz/interactive.py: dedup repeated status Div, log-transform closure, and 3D mesh cache key (+ first unit tests) #1518
toolchain/mfc/viz/interactive.py repeats three small, self-contained pieces of logic that are pure functions and trivially extractable. Dedup'ing them removes a live copy-paste hazard (change one copy, forget the others) and is a good opportunity to add the first automated tests for this module.
This is the low-risk subset carved out of the larger _update decomposition (tracked separately) — it touches no callback control flow and is unit-testable.
1. Status html.Div built 4× verbatim
Lines 1971, 2120, 2470, 2626 are the same 8-child html.Div (step {step} / · shape {raw.shape} / Br / min+value / max+value, same _YELLOW/_MUTED/_BLUE/_RED styles), differing only in the min/max local names.
→ add _status_div(step, shape, dmin, dmax) -> html.Div and call it at all four sites.
→ add _log_transform(log: bool) returning the transform (and the cmin/cmax pair, since sites 379/386 inline-compute those right next to the closure — extract them together so the cmin/cmax duplication doesn't get left behind). The 1e-300 floor should become a module constant _LOG_FLOOR at the same time.
3. 11-arg 3D mesh cache-key tuple repeated
The literal (step, var, mode, log, vmin_in, vmax_in, iso_min_frac, iso_max_frac, iso_n, vol_min_frac, vol_max_frac) appears at 350 (_prefetch_3d_mesh) and 432 (_get_cached_3d_mesh), and is passed positionally from _update at ~1890.
→ add _mesh3_key(...) -> tuple (or a small namedtuple) and use it at all three sites.
Tests
toolchain/mfc/viz/test_viz.py currently has no coverage of interactive.py at all. Add a few unit tests for _status_div, _log_transform, and _mesh3_key — these would be the first tests for this module and make the dedup verifiable.
Behavior preservation / risk: all three are pure-function extractions with no control-flow change; toolchain-only, no golden-file impact.
Filed from a repo-wide code-cleanliness review; verified against master @ 40dde5e.
I'd like to work on this issue. This is my first contribution to MFC. I'll start by writing the unit tests that capture the expected behavior, then implement the fix against them. I'll post back once I have a PR ready.
Activity
laolmstead commentedon Oct 26, 2026
I'd like to work on this issue. This is my first contribution to MFC. I'll start by writing the unit tests that capture the expected behavior, then implement the fix against them. I'll post back once I have a PR ready.