Skip to content

refactor(figure): allow at most one heatmap trace per figure - #112

Merged
jvdd merged 2 commits into
mainfrom
refactor/one-heatmap-per-figure
Sep 28, 2026
Merged

jvdd merged 2 commits into
mainfrom
refactor/one-heatmap-per-figure

Conversation

@jvdd

@jvdd jvdd commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Closes #101.

Stacked on #111 (both edit the heatmap section of Architecture.md and the heatmap tests in tests/test_spec.py). Merge #111 first; this PR then targets main.

Change

  • Figure.to_spec() raises ValueError when one figure holds more than one heatmap-like trace (histogram2d, geo_histogram2d, corr_heatmap). Dashboard.to_spec() calls Figure.to_spec() per figure, so it gets the check too.
  • The check replaces _validate_heatmap_styles and _effective_heatmap_style, which required several heatmaps in one figure to share color_scale, color_range and color_norm. The value checks they repeated stay in the trace helpers (normalize_heatmap_color_scale, normalize_heatmap_color_range, normalize_heatmap_color_norm), which every heatmap constructor and from_trace_spec call.
  • A heatmap together with other traces stays allowed, for example a line over a histogram2d, or a geo_line over a geo_histogram2d.
  • Architecture.md describes the new rule.

Impact

Tests

  • TestFigureHeatmapValidation is replaced by TestFigureHeatmapCount: a second heatmap raises (one case per heatmap type), a heatmap with a line or a geo_line builds, and the Dashboard path raises.
  • pytest tests flexviz_polars/tests: 2396 passed, 2 skipped.
  • pytest -m browser -k "heatmap or hist2d or geo or corr" tests: 33 passed, 1 skipped.

@codspeed

codspeed Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing refactor/one-heatmap-per-figure (f2aa7c3) with main (7a5f1fb)

Open in CodSpeed

Base automatically changed from fix/color-scale-names to main September 28, 2026 09:11
@jvdd
jvdd merged commit 8f9f588 into main Sep 28, 2026
18 checks passed
@jvdd
jvdd deleted the refactor/one-heatmap-per-figure branch September 28, 2026 09:44
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.

Allow at most one heatmap trace per figure

1 participant