refactor: unify color/cmap/norm pipeline — CmapParams methods + single continuous-norm#721
Merged
Merged
Conversation
b9373c6 to
9995c6f
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #721 +/- ##
==========================================
+ Coverage 77.41% 77.96% +0.54%
==========================================
Files 17 17
Lines 4486 4465 -21
Branches 1014 1003 -11
==========================================
+ Hits 3473 3481 +8
+ Misses 658 633 -25
+ Partials 355 351 -4
🚀 New features to boost your workflow:
|
… + single continuous-norm (#699) PRs 1+2 of #699, rebased onto the post-#715 (utils split) / post-#720 main. PR3 (image-composite helper) deferred. CmapParams gains behavior: - fresh_norm(): a safe per-element copy (applying a Normalize autoscales vmin/vmax in place, leaking one element's range into the next). Converts the 3 copy(norm) sites in render.py. - cmap_with_alpha() / colormap_with_alpha(): public-API replacement for the private cmap._lut[:, -1] = alpha poke in the 1-channel image path; byte-identical body colors, no shared-cmap mutation. Single continuous-norm feeds pixels and colorbar: - _resolve_continuous_norm(values, cmap_params) in _color.py: one resolver called by each pixel-baking site and its matching colorbar site with the same vector, so they cannot diverge. Folds the duplicated inline norm blocks in _color_vector_to_rgba and _get_collection_shape (now in _geometry.py; its dead `norm` param dropped) and routes _map_color_seg + the labels imshow + _append_outline_colorbar + the shapes set_clim through it. - Datashader / image / points / graph paths unchanged (already share their norm). Behavior-preserving for normal renders; the only unified edge is an all-identical-value outline column. Adds unit tests for the new CmapParams methods and _resolve_continuous_norm plus a non-visual colorbar-clim integration test.
9995c6f to
1fd8b48
Compare
timtreis
added a commit
that referenced
this pull request
Jun 15, 2026
…regression) The resolver returned a plain Normalize, silently linearizing LogNorm/PowerNorm/ SymLogNorm for shapes/points/labels (the old _get_collection_shape used the user norm directly). Now copies the norm and fills vmin/vmax, keeping the subclass. Verified: zero baseline shift on the 5 render/colorbar test files (only the untested non-linear-norm path changes); images are unaffected (norm → imshow).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PRs 1+2 of #699 (color/cmap/norm unification), rebased onto current main (post-#715 utils split / #720). PR3 (image-composite helper) deferred.
Commit —
CmapParamsgains behavior + one continuous-norm for pixels and colorbar.fresh_norm(): a safe per-element norm copy (applying aNormalizeautoscalesvmin/vmaxin place, leaking one element's range into the next). Replaces thecopy(cmap_params.norm)sites.colormap_with_alpha(): public-API replacement for the privatecmap._lut[:, -1] = alphapoke in the 1-channel image path; byte-identical body colors, alpha applied to body + bad + under/over, no shared-cmap mutation._resolve_continuous_norm(values, cmap_params): one resolver called by each pixel-baking site and its colorbar site with the same vector, so they can't diverge; folds the duplicated inline norm blocks (_color_vector_to_rgba,_get_collection_shape— its deadnormparam dropped,_map_color_seg, the labels imshow,_append_outline_colorbar, the shapesset_clim). Datashader / image / points / graph paths unchanged (already share their norm).Behavior note: behavior-preserving for normal (multi-value) renders. One intentional change for constant-valued continuous columns: the old code reset a degenerate
vmin == vmaxto[0, 1]only on the shapes-fill/outline path (labels already autoscaled to the degenerate range), so the two paths disagreed. The resolver unifies them — a constant-valued shapes column now maps tocmap(0)like labels already did, instead of the colormap top. Visualtest_plot_*baselines for any such fixture shift and are regenerated from CI artifacts.Tests: unit tests for
fresh_norm,colormap_with_alpha, and_resolve_continuous_norm; a non-visual test asserting the fill colorbar clim equals the resolved data range.