Skip to content

Commit 591fc21

Browse files
committed
MNT: simplify validation logic
hat tip to @anntzer
1 parent bc4f649 commit 591fc21

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/matplotlib/figure.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,22 +1638,19 @@ def _process_layout(layout):
16381638

16391639
def _do_layout(gs, layout, unique_ids, nested):
16401640
rows, cols = layout.shape
1641-
covered = np.zeros((rows, cols), dtype=bool)
16421641
output = dict()
16431642

1644-
for j, k in np.argwhere(layout == empty_sentinel):
1645-
covered[j, k] = True
1646-
16471643
for name in unique_ids:
1644+
if name == empty_sentinel:
1645+
continue
1646+
16481647
indx = np.argwhere(layout == name)
16491648
start_row, start_col = np.min(indx, axis=0)
16501649
end_row, end_col = np.max(indx, axis=0) + 1
16511650
slc = (slice(start_row, end_row), slice(start_col, end_col))
1652-
if np.any(covered[slc]):
1651+
1652+
if (layout[slc] != name).any():
16531653
raise ValueError
1654-
covered[slc] = True
1655-
if name == empty_sentinel:
1656-
continue
16571654

16581655
if hasattr(name, 'set_subplotspec'):
16591656
ax = name

0 commit comments

Comments
 (0)