From 65281f6a79ee801aa2f8ed6f34dd3c03458d7b2b Mon Sep 17 00:00:00 2001 From: anon Date: Fri, 8 May 2026 12:29:14 +0200 Subject: [PATCH] Fix render_labels silently rendering invisible labels when fill_alpha=0 and outline_alpha=0 (#630) The dispatch chain's first branch matched `fill_alpha == outline_alpha`, routing the (0, 0) case to the fill-only path with alpha=0 and leaving the existing ValueError as dead code. Add an explicit guard so the error is actually raised. --- src/spatialdata_plot/pl/render.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/spatialdata_plot/pl/render.py b/src/spatialdata_plot/pl/render.py index fc28a540..4f1894f5 100644 --- a/src/spatialdata_plot/pl/render.py +++ b/src/spatialdata_plot/pl/render.py @@ -1764,6 +1764,11 @@ def _draw_labels( if effective_outline_color is None and col_for_color is None and render_params.color is not None: effective_outline_color = render_params.color + if render_params.fill_alpha == 0.0 and render_params.outline_alpha == 0.0: + raise ValueError( + "Parameters 'fill_alpha' and 'outline_alpha' cannot both be 0. Set at least one to a positive value." + ) + # default case: no contour, just fill # since contour_px is passed to skimage.morphology.erosion to create the contour, # any border thickness is only within the label, not outside. Therefore, the case