Skip to content

Commit 11dbd79

Browse files
timtreisclaude
andcommitted
Add empty-layers guard to _additive_blend, clarify scalar_norm comment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fd051a2 commit 11dbd79

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/spatialdata_plot/pl/basic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,9 @@ def render_images(
597597
n_steps = len(sdata.plotting_tree.keys())
598598

599599
for element, param_values in params_dict.items():
600-
# When norm is a list, per-channel norms are stored separately in ImageRenderParams.norms
601-
# and _prepare_cmap_norm receives None so it creates a default (unused) norm.
600+
# Per-channel norms are stored in ImageRenderParams.norms. In that case
601+
# _prepare_cmap_norm gets None and creates a default norm used as fallback
602+
# for the single-channel rendering path.
602603
scalar_norm = None if isinstance(norm, list) else norm
603604
cmap_params: list[CmapParams] | CmapParams
604605
if isinstance(cmap, list):

src/spatialdata_plot/pl/render.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,8 @@ def _additive_blend(
12011201
reasonable result by extracting each cmap's contribution relative to its
12021202
own background.
12031203
"""
1204+
if not layers:
1205+
raise ValueError("Cannot blend an empty set of layers.")
12041206
height, width = next(iter(layers.values())).shape
12051207
zero_colors = np.array([cm(0.0)[:3] for cm in channel_cmaps])
12061208
canvas = np.mean(zero_colors, axis=0)

0 commit comments

Comments
 (0)