Skip to content

Commit 7cb3133

Browse files
authored
Raise clear error for all-empty shapes (#674)
1 parent 53421a5 commit 7cb3133

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/spatialdata_plot/pl/basic.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,18 @@ def _draw_colorbar(
15251525
if fig_params.frameon is False:
15261526
ax.axis("off")
15271527

1528+
if has_shapes and wants_shapes:
1529+
empty_shape_elements = [
1530+
name
1531+
for name in wanted_elements
1532+
if name in sdata.shapes and not sdata.shapes[name]["geometry"].apply(lambda g: not g.is_empty).any()
1533+
]
1534+
if empty_shape_elements:
1535+
raise ValueError(
1536+
f"Cannot render shape element(s) {empty_shape_elements} in coordinate system {cs!r}: "
1537+
"all geometries are empty. Drop the element or restore at least one non-empty geometry."
1538+
)
1539+
15281540
extent = get_extent(
15291541
sdata,
15301542
coordinate_system=cs,

0 commit comments

Comments
 (0)