Skip to content

Commit 8dae147

Browse files
timtreisclaude
andcommitted
Fix cmap validation comparing against full image channels instead of selected
When user specifies `channel=[0]` on a 3-channel image with `cmap=['gray']`, the cmap matched the selected channel count but was nullified because it didn't match the full image channel count. Now the comparison uses the selected channel count (or full count when no channel is specified). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 79b99fa commit 8dae147

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/spatialdata_plot/pl/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,10 +2867,10 @@ def _validate_image_render_params(
28672867

28682868
cmap = param_dict["cmap"]
28692869
if cmap is not None:
2870+
expected_len = len(channel) if channel is not None else len(spatial_element_ch)
28702871
if len(cmap) == 1:
2871-
cmap_length = len(channel) if channel is not None else len(spatial_element_ch)
2872-
cmap = cmap * cmap_length
2873-
if (channel is not None and len(cmap) != len(channel)) or len(cmap) != len(spatial_element_ch):
2872+
cmap = cmap * expected_len
2873+
if len(cmap) != expected_len:
28742874
cmap = None
28752875
element_params[el]["cmap"] = cmap
28762876
element_params[el]["norm"] = param_dict["norm"]

0 commit comments

Comments
 (0)