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

Skip to content

Commit 84b9a88

Browse files
authored
Merge pull request #19640 from meeseeksmachine/auto-backport-of-pr-19639-on-v3.4.x
Backport PR #19639 on branch v3.4.x (FIX: do not allow single element list of str in subplot_mosaic)
2 parents f8305e5 + 62783af commit 84b9a88

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,8 @@ def _make_array(inp):
16921692
16931693
"""
16941694
r0, *rest = inp
1695+
if isinstance(r0, str):
1696+
raise ValueError('List layout specification must be 2D')
16951697
for j, r in enumerate(rest, start=1):
16961698
if isinstance(r, str):
16971699
raise ValueError('List layout specification must be 2D')

lib/matplotlib/tests/test_figure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,8 @@ def test_empty(self, fig_test, fig_ref, x, empty_sentinel):
760760
def test_fail_list_of_str(self):
761761
with pytest.raises(ValueError, match='must be 2D'):
762762
plt.subplot_mosaic(['foo', 'bar'])
763+
with pytest.raises(ValueError, match='must be 2D'):
764+
plt.subplot_mosaic(['foo'])
763765

764766
@check_figures_equal(extensions=["png"])
765767
@pytest.mark.parametrize("subplot_kw", [{}, {"projection": "polar"}, None])

0 commit comments

Comments
 (0)