Commit 15fc496
committed
refactor(render): give CmapParams norm/cmap behavior, drop private _lut poke (#699)
PR1 of the #699 color/cmap/norm unification. Adds behavior to CmapParams so
callers stop re-implementing stateful-object handling:
- fresh_norm(): a safe copy of the norm. Applying a Normalize autoscales
vmin/vmax in place, so sharing it leaks one element's range into the next.
Converts the 4 hand-written copy(cmap_params.norm) sites (render_shapes,
render_points, render_labels-as-points, datashader outline) to use it.
- cmap_with_alpha() / colormap_with_alpha(): a public-API replacement for the
private cmap._lut[:, -1] = alpha poke in the 1-channel image path. Rebuilds the
colormap via a lossless N-bin resample (matplotlib quantizes __call__ to N bins,
so body colors are byte-identical), preserves the cmap name, and reproduces the
old bad/NaN-pixel alpha behavior. Also stops mutating the shared cmap in place.
Behavior-preserving except the bad-pixel alpha at alpha<1 with NaN pixels, which
is reproduced exactly. Adds unit tests for the new CmapParams methods.
Out of scope (deferred to PR2): unifying _map_color_seg's shared-norm mutation —
the continuous labels colorbar currently depends on that in-place autoscale, so it
must be fixed together with the colorbar's norm derivation.1 parent 7a1b3a3 commit 15fc496
4 files changed
Lines changed: 88 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
572 | 571 | | |
573 | 572 | | |
574 | 573 | | |
575 | | - | |
| 574 | + | |
576 | 575 | | |
577 | 576 | | |
578 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
741 | 742 | | |
742 | 743 | | |
743 | 744 | | |
744 | | - | |
| 745 | + | |
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
| |||
1505 | 1506 | | |
1506 | 1507 | | |
1507 | 1508 | | |
1508 | | - | |
| 1509 | + | |
1509 | 1510 | | |
1510 | 1511 | | |
1511 | 1512 | | |
| |||
1966 | 1967 | | |
1967 | 1968 | | |
1968 | 1969 | | |
1969 | | - | |
1970 | | - | |
1971 | | - | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
1972 | 1973 | | |
1973 | 1974 | | |
1974 | 1975 | | |
| |||
2426 | 2427 | | |
2427 | 2428 | | |
2428 | 2429 | | |
2429 | | - | |
| 2430 | + | |
2430 | 2431 | | |
2431 | 2432 | | |
2432 | 2433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
151 | 168 | | |
152 | 169 | | |
153 | 170 | | |
| |||
157 | 174 | | |
158 | 175 | | |
159 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
160 | 194 | | |
161 | 195 | | |
162 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
509 | | - | |
510 | | - | |
| 508 | + | |
511 | 509 | | |
512 | 510 | | |
513 | 511 | | |
| |||
547 | 545 | | |
548 | 546 | | |
549 | 547 | | |
550 | | - | |
551 | | - | |
552 | | - | |
| 548 | + | |
553 | 549 | | |
554 | 550 | | |
555 | 551 | | |
| |||
635 | 631 | | |
636 | 632 | | |
637 | 633 | | |
638 | | - | |
| 634 | + | |
639 | 635 | | |
640 | 636 | | |
641 | 637 | | |
| |||
814 | 810 | | |
815 | 811 | | |
816 | 812 | | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
0 commit comments