Commit 6b1ce2a
committed
Make ListedColormap.monochrome a property
The calculated property replaces the attribute *monochome*, which was
manually set on `__init__`, but was not correctly set for all possible
inputs.
This property ensures consistency and simplifies initialization at the
cost of some computation overhead to determine whether the colormap is
monochrome.
The computation cost is bearable (even without caching), because it's
only used in `ContourSet._process_colors`.
It's a separate discussion whether we need this property on colormaps at
all (at least as public API). Usually, colormaps are not monochrome
and monochrome colormaps are a very special edge case used in contours
only. We may eventually deprecate it, but since it is currently public
API, let's leave it for now.
There's also a technical API incompatibility in that users cannot set
the attribute anymore, but I'd argue that that has never been intended
and there's no practical use-case, so I refrain from the extra hassle
of allowing setting this property.1 parent ca39d41 commit 6b1ce2a
3 files changed
+26
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
1194 | | - | |
1195 | 1194 | | |
1196 | 1195 | | |
1197 | 1196 | | |
1198 | 1197 | | |
1199 | 1198 | | |
1200 | 1199 | | |
1201 | | - | |
1202 | 1200 | | |
1203 | | - | |
1204 | | - | |
1205 | 1201 | | |
1206 | 1202 | | |
1207 | 1203 | | |
| |||
1211 | 1207 | | |
1212 | 1208 | | |
1213 | 1209 | | |
1214 | | - | |
1215 | 1210 | | |
1216 | 1211 | | |
1217 | 1212 | | |
| |||
1220 | 1215 | | |
1221 | 1216 | | |
1222 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1223 | 1236 | | |
1224 | 1237 | | |
1225 | 1238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | 133 | | |
135 | 134 | | |
136 | 135 | | |
137 | 136 | | |
| 137 | + | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
| |||
0 commit comments