Skip to content

v0.2: diverging metrics (time or money saved, either sign), missing values in grey, a comparison example - #3

Merged
yamierick merged 1 commit into
mainfrom
v0.2-diverging
Sep 29, 2026
Merged

yamierick merged 1 commit into
mainfrom
v0.2-diverging

Conversation

@yamierick

Copy link
Copy Markdown
Contributor

Suggested by Dr. Jones (2026-09-28) after the HSR door-to-door maps: time saved by one option against another is a difference that can be either sign, and v0.1 only had sequential log scales. This adds a diverging scale and an example. Everything uses synthetic data only, as the repo's rules require.

What changes

  • colour.diverging() gives orange below the centre, a pale middle and blue above. colour.diverging_norm(lo, hi, centre=0) sets the scale. Legends mark both clipped ends (≤, ≥).
  • Missing values (NaN) are one neutral grey, colour.MISSING, per metric. So "against air" can be grey where no airport is in reach, while the same hexagon stays coloured under "against the car".
  • Metric.cmap also accepts a Colormap. Metric.note puts the colour meaning on the legend. Its default reproduces v0.1's "darker is higher (log scale)", so existing specs draw identical pages.
  • On the 3D page, column height is the value's size, either sign; the colour gives the sign.
  • fmt.signed(unit, digits) formats values like "+0.4 h" and "−1.2 h", with a true minus sign.
  • examples/synthetic_comparison.py uses two made-up cities, a town with no airport, and a new service between the cities. It has three metrics (against the faster alternative, the car, air) and two views (trips each way). It also shows how to bin a quantity that is not additive: sum people × hours and people, then divide.

Version is 0.2.0, with the CHANGELOG and README updated.

Checked

  • 20 tests pass; ruff check is clean.
  • New tests cover:
    • the diverging legend's positions and end marks;
    • end and missing colours;
    • the signed format;
    • the example conserving people and the people-weighted mean;
    • grey and a dash where air is missing;
    • 3D height as the absolute maximum;
    • v0.1's default note unchanged.
  • Both example pages checked in a browser, all three metrics, both views. Town C is grey under "against air" and orange elsewhere.

After merge

Please tag v0.2.0. hsr-robotaxi-scenarios pins this branch's commit until the tag exists, then moves to the tag.

🤖 Generated with Claude Code

For a difference that can be either sign, such as door-to-door time saved
by one option against another. Backwards compatible: a 0.1 spec draws the
same pages.

- colour.diverging() and colour.diverging_norm(lo, hi, centre); legends
  mark both clipped ends. A NaN is colour.MISSING grey on every metric.
- Metric.cmap takes a Colormap; Metric.note says what the colours mean
  (default "darker is higher (log scale)", as before).
- 3D column height is the value's size either sign.
- fmt.signed(unit, digits) with a true minus sign.
- examples/synthetic_comparison.py: made-up cities, a new service against
  the faster alternative, the car and air; binning a non-additive saving
  as people x hours over people. Tested end to end.

20 tests pass; ruff clean. Both pages checked in a browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yamierick
yamierick merged commit e4adc2f into main Sep 29, 2026
1 check 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.

1 participant