Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6606961

Browse files
committed
MNT: catch more invalid input
1 parent 14aa049 commit 6606961

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/figure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,8 @@ def _do_layout(gs, layout, unique_ids, nested):
17021702
gs[slc], **{'label': str(name), **subplot_kw})
17031703

17041704
for (j, k), nested_layout in nested.items():
1705+
if not all(len(r) for r in nested_layout):
1706+
raise ValueError("All of the rows must be the same length")
17051707
nested_layout = np.asarray(nested_layout, dtype=object)
17061708
rows, cols = nested_layout.shape
17071709
gs_n = gs[j, k].subgridspec(rows, cols, **gridspec_kw)
@@ -1714,7 +1716,8 @@ def _do_layout(gs, layout, unique_ids, nested):
17141716
f"and the nested layout\n{nested_layout}")
17151717
output.update(nested_output)
17161718
return output
1717-
1719+
if not all(len(r) for r in layout):
1720+
raise ValueError("All of the rows must be the same length")
17181721
layout = np.asarray(layout, dtype=object)
17191722
rows, cols = layout.shape
17201723
gs = self.add_gridspec(rows, cols, **gridspec_kw)

0 commit comments

Comments
 (0)