Skip to content

Commit 99119d4

Browse files
jjhbarkeywolfjjhbw
authored andcommitted
Solved TypeError: 'Polygon' object is not iterable when trying to build a MultiPolygon from a list with only a single Polygon in it.
1 parent c0cfb16 commit 99119d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

infer_simple.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ def construct_tissue_polygon(foreground_contours, hole_contours, min_area):
9191

9292
polys.append(poly)
9393

94-
# Combine all polygons into a MultiPolygon
95-
return MultiPolygon(unary_union(polys))
94+
if len(polys) == 0:
95+
raise Exception("Raw tissue mask consists of 0 polygons")
96+
97+
# If we have multiple polygons, we merge any overlap between them using unary_union().
98+
# This will result in a Polygon or MultiPolygon with most tissue masks.
99+
return unary_union(polys)
96100

97101

98102
def make_tile_QC_fig(tile_sets, slide, level, line_width_pix):

0 commit comments

Comments
 (0)