Skip to content

v0.3: toggles (season, time of day ...), a signed log scale, thinner log legends - #4

Merged
yamierick merged 1 commit into
mainfrom
v0.3-toggles
Sep 29, 2026
Merged

yamierick merged 1 commit into
mainfrom
v0.3-toggles

Conversation

@yamierick

Copy link
Copy Markdown
Contributor

Stacked on #3 (v0.2, diverging). Merge #3 first; this PR then retargets to main. Tag v0.3.0 after merging: sear-labs/ercot-grid-analysis pins this branch's commit until the tag exists.

Asked for by Dr. Jones for the ERCOT maps: a demand tab, a net tab that can go negative (net consumers against net generators), and season and time of day as toggles that apply to every tab.

What's new

Toggle, MapSpec.toggles, slice_key Rows of option buttons. Every combination of options is a slice. A column named slice_key(key, option, ...) is sliced. These switch with the slice: metrics, cell fields that repeat a metric, the split, area fields and rankings. The legend and cards name the slice.
Compact slices A sliced metric is stored once, as a table of its distinct values (3 significant figures by default, slice_digits) with each value's text and colour. Each cell keeps one index per slice. The ERCOT page (25 slices, 9 metrics, 1,700 hexagons) is about 7 MB; stored plainly it would be about 40. The page copies the chosen slice into the fields the drawing code already reads, so the drawing code is unchanged.
3D heights Scaled to the tallest value over every slice, so heights compare between slices.
colour.signed_log_norm Diverging, linear within ±linthresh, logarithmic beyond. For net flows that span decades on both sides of zero.
Log legends At most six labels, both ends kept. In v0.2 every doubling was labelled, and the labels overlapped on a legend 300–400 px wide (measured on the ERCOT page).
Refused, with a message A column sliced for only some slices; a metric sliced in only some views; a sliced cell field that isn't a sliced metric.

It is backwards compatible: a v0.2 spec draws the same pages, apart from the thinner legend labels.

Checks

  • 26 tests pass; ruff is clean.
  • New test: every slice of examples/synthetic_toggles.py is read back from both pages and matches the binned values to 3 significant figures. The test also covers mixed-radix slice order, heights across slices, and split shares.
  • Browser, both pages: toggles switch colours, the legend, cards and heights (deck.gl update triggers include the slice). No console errors.
  • Real use: the ERCOT map, checked the same way. A slice switches in about 20 ms on the 2D page.
  • The templates-generic test still passes: no project wording in the templates.

🤖 Generated with Claude Code

…log legends

- Toggle and MapSpec.toggles: every combination of options is a slice. Columns named
  slice_key(key, option, ...) are sliced; metrics, cell fields that repeat a metric, the split,
  area fields and rankings switch with the toggles; legend and cards name the slice.
- A sliced metric is one table of distinct values (3 significant figures by default) with text
  and colour, plus an index per cell and slice: 25 slices x 9 metrics x 1,700 hexagons is about
  7 MB instead of about 40.
- 3D heights scale to the tallest value over every slice.
- colour.signed_log_norm: diverging, linear near zero, log beyond, for net flows.
- Log legends label at most six doublings, both ends kept (0.2 labels overlapped).
- examples/synthetic_toggles.py, tested end to end: every slice read back from the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yamierick
yamierick changed the base branch from v0.2-diverging to main September 29, 2026 06:04
@yamierick
yamierick merged commit f2f0753 into main Sep 29, 2026
1 check passed
@yamierick
yamierick deleted the v0.3-toggles branch September 29, 2026 06:04
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