Skip to content

Commit b87aa2a

Browse files
authoredApr 5, 2022
fix #131 (#132)
* fix #131 * more comments
1 parent 1a9b586 commit b87aa2a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/layoutparser/visualization.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def draw_box(
318318
font_obj = _create_font_object(id_font_size, id_font_path)
319319

320320
if box_alpha is None:
321-
box_alpha = [0]
321+
box_alpha = [0] * len(layout)
322322
else:
323323
if isinstance(box_alpha, (float, int)):
324324
box_alpha = [box_alpha] * len(layout)
@@ -363,6 +363,11 @@ def draw_box(
363363
f"The number of colors {len(box_color)} is not equal to the number of blocks {len(layout)}"
364364
)
365365

366+
# A post check of the lengths of the input lists
367+
# To support more versions of python, we do not use
368+
# zip(*, strict=True)
369+
assert len(layout) == len(box_color) == len(box_alpha) == len(box_width)
370+
366371
for idx, (ele, color, alpha, width) in enumerate(
367372
zip(layout, box_color, box_alpha, box_width)
368373
):

0 commit comments

Comments
 (0)