Skip to content

Commit fe75761

Browse files
timtreisclaude
andcommitted
Use Color.get_alpha_as_float() instead of comparing internal hex string
Replace stringly-typed `_na.alpha == "00"` with the public accessor `_na.get_alpha_as_float() == 0.0` in all three groups-filtering guards. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8da18d2 commit fe75761

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/spatialdata_plot/pl/render.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _render_shapes(
275275
# When groups are specified, filter out non-matching elements by default.
276276
# Only show non-matching elements if the user explicitly sets na_color.
277277
_na = render_params.cmap_params.na_color
278-
if groups is not None and values_are_categorical and (_na.default_color_set or _na.alpha == "00"):
278+
if groups is not None and values_are_categorical and (_na.default_color_set or _na.get_alpha_as_float() == 0.0):
279279
keep, color_source_vector, color_vector = _filter_groups_transparent_na(
280280
groups, color_source_vector, color_vector
281281
)
@@ -887,7 +887,8 @@ def _render_points(
887887
# When groups are specified, filter out non-matching elements by default.
888888
# Only show non-matching elements if the user explicitly sets na_color.
889889
_na = render_params.cmap_params.na_color
890-
if groups is not None and color_source_vector is not None and (_na.default_color_set or _na.alpha == "00"):
890+
na_is_transparent = _na.default_color_set or _na.get_alpha_as_float() == 0.0
891+
if groups is not None and color_source_vector is not None and na_is_transparent:
891892
keep, color_source_vector, color_vector = _filter_groups_transparent_na(
892893
groups, color_source_vector, color_vector
893894
)
@@ -1525,7 +1526,7 @@ def _render_labels(
15251526
groups is not None
15261527
and categorical
15271528
and color_source_vector is not None
1528-
and (_na.default_color_set or _na.alpha == "00")
1529+
and (_na.default_color_set or _na.get_alpha_as_float() == 0.0)
15291530
):
15301531
keep_vec = color_source_vector.isin(groups)
15311532
matching_ids = instance_id[keep_vec]

0 commit comments

Comments
 (0)