Skip to content

Commit b0c1cde

Browse files
committed
Raise ValueError on invalid scale in render_images
Previously, render_images(scale="...") silently reset an unknown scale name to None and auto-picked a resolution, discarding the user's intent without warning. The downstream _multiscale_to_spatial_image already had the right ValueError but was unreachable because the value was cleared beforehand. Validate at the entry point and surface the error with the list of valid scales. Closes #623
1 parent 29b1cc1 commit b0c1cde

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/spatialdata_plot/pl/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,12 +3007,12 @@ def _validate_image_render_params(
30073007
element_params[el]["norm"] = norm
30083008
scale = param_dict["scale"]
30093009
if scale and isinstance(param_dict["sdata"][el], DataTree):
3010-
if scale not in list(param_dict["sdata"][el].keys()) and scale != "full":
3011-
element_params[el]["scale"] = None
3012-
else:
3013-
element_params[el]["scale"] = scale
3014-
else:
3015-
element_params[el]["scale"] = scale
3010+
valid_scales = list(param_dict["sdata"][el].keys())
3011+
if scale not in valid_scales and scale != "full":
3012+
raise ValueError(
3013+
f"Scale '{scale}' does not exist in image '{el}'. Valid scales: {valid_scales + ['full']}."
3014+
)
3015+
element_params[el]["scale"] = scale
30163016
element_params[el]["colorbar"] = param_dict["colorbar"]
30173017
element_params[el]["colorbar_params"] = param_dict["colorbar_params"]
30183018

0 commit comments

Comments
 (0)