Skip to content

Add overlay unit validation#871

Draft
SimonHeybrock wants to merge 2 commits into
mainfrom
fix-overlay-unit-validation
Draft

Add overlay unit validation#871
SimonHeybrock wants to merge 2 commits into
mainfrom
fix-overlay-unit-validation

Conversation

@SimonHeybrock
Copy link
Copy Markdown
Member

Summary

  • Validates that overlaid data sources share compatible units, preventing silent incorrect plots where HoloViews renders mismatched units against a single shared axis
  • Site 1 (intra-layer): checks dimension names, coordinate units, and value units across all DataArrays within a single plotter's compute()
  • Site 2 (cross-layer): checks unit compatibility across layers in the same cell before composing DynamicMaps
  • ROI readback/request plotters participate in kdim validation but skip vdim checks (their "values" are geometric metadata, not physical quantities)

Closes #870

Test plan

  • Configure a dashboard with two monitors producing different coordinate units in the same cell — verify error message appears in the plot area
  • Configure a dashboard with two monitors producing different value units — verify error message
  • Verify normal overlays (matching units) still render correctly
  • Verify ROI overlays on images still work (kdim units match, vdim skipped)

🤖 Generated with Claude Code

HoloViews silently renders overlaid elements against a single shared axis
using the first element's units, producing incorrect plots when sources
have mismatched units. This adds validation at two sites:

Site 1 (Plotter.compute): validates that all DataArrays in an overlay
share the same dimension names, coordinate units, and value units.
Errors are caught by the existing try/except and displayed as text.

Site 2 (_get_session_composed_plot): validates cross-layer unit
compatibility before composing DynamicMaps. Each Plotter stores an
OverlayUnitKey after compute(), which captures kdim and vdim unit
metadata. ROI readback/request plotters provide kdim units from their
coordinate metadata but skip vdim validation. Static plotters are
naturally exempt (no Plotter instance).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SimonHeybrock SimonHeybrock force-pushed the fix-overlay-unit-validation branch from 2df79e8 to 1852b76 Compare April 15, 2026 06:06
Replace OverlayUnitKey (lossy string-based, weak cross-layer check) with
CanvasSpec - a frozen dataclass holding coord_units and value_unit as native
sc.Unit values. One validation function (validate_overlay_units) now serves
both intra-layer and cross-layer sites with full consistency checks.

ROI and annotation plotters opt out via participates_in_overlay_validation
class flag, eliminating three _extract_overlay_unit_key overrides.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@SimonHeybrock SimonHeybrock force-pushed the fix-overlay-unit-validation branch from 1852b76 to af4b525 Compare April 15, 2026 06:21
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.

Overlay silently mixes elements with different coordinate or value units

1 participant