Skip to content

fix: serve cmocean and crameri colormaps in their published orientation - #141

Open
matthiasschabel wants to merge 1 commit into
pyapp-kit:mainfrom
matthiasschabel:fix-cmocean-crameri-orientation
Open

fix: serve cmocean and crameri colormaps in their published orientation#141
matthiasschabel wants to merge 1 commit into
pyapp-kit:mainfrom
matthiasschabel:fix-cmocean-crameri-orientation

Conversation

@matthiasschabel

Copy link
Copy Markdown

Twelve colormaps in the catalog are served in an orientation their upstream projects don't publish — nine cmocean maps stored end-for-end reversed, and three crameri maps still carrying Scientific Colour Maps 7 tables that SCM 8 reversed and revised. This PR fixes the data files; no code changes.

cmocean: nine tables are bit-exact reversals of upstream

Comparing every cmocean:* base entry at 256 samples against the cmocean package's own loader (cmocean 3.0.3, which renders its published gallery), max abs channel difference in 8-bit units:

map as-is Δ flipped Δ
algae 212.9 0.0
amp 227.9 0.0
deep 227.4 0.0
dense 226.5 0.0
matter 222.2 0.0
rain 210.8 0.0
speed 231.8 0.0
tempo 233.7 0.0
turbid 215.3 0.0

Flipped Δ = 0 means the stored table is exactly cmocean's, read backwards. The rest of the namespace matches forward exactly (thermal, haline, ice, solar, curl, balance, …, and the cropped balance_blue/curl_pink/delta_blue match cmocean's rgb/*-rgb.py source files as-is), so this is per-map, not a convention difference. The fix reverses the row order in the nine data files; every float literal is unchanged.

crameri: three tables are stale SCM 7 — this completes #83

bilbao, grayC and lajolla are bit-exact matches of SCM 7.0.1 (zenodo 5501399, the __source__ they cite). Fabio Crameri reversed all three in SCM 8 and revised their values beyond the flip — after reversal they still differ from 8.0.1 by up to 35/255 per channel, so a plain flip wouldn't be any published version. #83 updated the namespace to v8's new maps (naviaW here is 8.0.1-exact) but didn't refresh the tables v8 revised.

These three files are regenerated from the SCM 8.0.1 deposit (zenodo 8409685, the same pin naviaW cites), formatted like the #83 additions, __source__ updated.

Reproduce

import numpy as np, cmap, cmocean
grid = np.linspace(0, 1, 256)
ours = np.asarray(cmap.Colormap("cmocean:algae")(grid))[:, :3]
theirs = np.asarray(cmocean.cm.algae(grid))[:, :3]
print(np.abs(ours - theirs).max() * 255)        # ~213 before, ~0 after
print(np.abs(ours - theirs[::-1]).max() * 255)  # ~0 before (bit-exact reversal)

Notes

  • This is a visible change for anyone relying on the current orientation of these twelve names; that seemed preferable to permanently diverging from what the upstream projects publish and render in their galleries, but flagging it for the changelog.
  • The test suite passes locally (the two okabe_ito matplotlib-parity failures exist on main with matplotlib ≥ 3.10 and are unrelated).
  • Happy to split cmocean and crameri into separate PRs if that's easier to review.

🤖 Generated with Claude Code

Nine cmocean tables (algae, amp, deep, dense, matter, rain, speed, tempo,
turbid) were stored end-for-end reversed relative to the cmocean project's
own data: bit-exact reversals of what cmocean 3.0.3 loads from its rgb
source files. Reversed in place; every literal is unchanged, only row order.

crameri bilbao, grayC and lajolla were still the Scientific Colour Maps
7.0.1 tables: SCM 8 reversed those three and revised their values (up to
35/255 per channel after the flip). pyapp-kit#83 added the maps v8 introduced but
kept the v7 tables for the ones it revised. Regenerated from the 8.0.1
deposit (zenodo 8409685), matching naviaW's source pin.
@matthiasschabel
matthiasschabel marked this pull request as ready for review August 4, 2026 20:06
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