Skip to content

Commit b6f6912

Browse files
author
Sonja Stockhaus
committed
bugfix and add test
1 parent 6ffe22b commit b6f6912

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/spatialdata_plot/pl/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,18 +1897,18 @@ def _validate_image_render_params(
18971897

18981898
if isinstance(palette := param_dict["palette"], list):
18991899
if len(palette) == 1:
1900-
palette_length = len(channel) if channel is not None else len(spatial_element.c)
1900+
palette_length = len(channel) if channel is not None else len(spatial_element_ch)
19011901
palette = palette * palette_length
1902-
if (channel is not None and len(palette) != len(channel)) and len(palette) != len(spatial_element.c):
1902+
if (channel is not None and len(palette) != len(channel)) and len(palette) != len(spatial_element_ch):
19031903
palette = None
19041904
element_params[el]["palette"] = palette
19051905
element_params[el]["na_color"] = param_dict["na_color"]
19061906

19071907
if (cmap := param_dict["cmap"]) is not None:
19081908
if len(cmap) == 1:
1909-
cmap_length = len(channel) if channel is not None else len(spatial_element.c)
1909+
cmap_length = len(channel) if channel is not None else len(spatial_element_ch)
19101910
cmap = cmap * cmap_length
1911-
if (channel is not None and len(cmap) != len(channel)) or len(cmap) != len(spatial_element.c):
1911+
if (channel is not None and len(cmap) != len(channel)) or len(cmap) != len(spatial_element_ch):
19121912
cmap = None
19131913
element_params[el]["cmap"] = cmap
19141914
element_params[el]["norm"] = param_dict["norm"]

tests/pl/test_render_images.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,6 @@ def test_plot_can_stack_render_images(self, sdata_blobs: SpatialData):
125125

126126
def test_plot_can_stick_to_zorder(self, sdata_blobs: SpatialData):
127127
sdata_blobs.pl.render_shapes().pl.render_images().pl.show()
128+
129+
def test_plot_can_render_multiscale_image_with_custom_cmap(self, sdata_blobs: SpatialData):
130+
sdata_blobs.pl.render_images("blobs_multiscale_image", channel=0, scale="scale2", cmap="Greys").pl.show()

0 commit comments

Comments
 (0)