Skip to content

Commit 55ef3ef

Browse files
committed
TST: improve the tests
1 parent 6db802d commit 55ef3ef

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

lib/matplotlib/tests/test_subplots.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,35 @@ def test_subplot_factory_reapplication():
214214
assert maxes.subplot_class_factory(maxes.Subplot) is maxes.Subplot
215215

216216

217+
@pytest.mark.parametrize("width_ratios", [None, [1, 3, 2]])
218+
@pytest.mark.parametrize("height_ratios", [None, [1, 2]])
217219
@check_figures_equal(extensions=['png'])
218-
def test_width_and_height_ratios(fig_test, fig_ref):
219-
fig_test.subplots(2, 3, height_ratios=[1, 2],
220-
width_ratios=[1, 3, 2])
220+
def test_width_and_height_ratios(fig_test, fig_ref,
221+
height_ratios, width_ratios):
222+
fig_test.subplots(2, 3, height_ratios=height_ratios,
223+
width_ratios=width_ratios)
221224
fig_ref.subplots(2, 3, gridspec_kw={
222-
'height_ratios': [1, 2],
223-
'width_ratios': [1, 3, 2]})
225+
'height_ratios': height_ratios,
226+
'width_ratios': width_ratios})
224227

225228

229+
@pytest.mark.parametrize("width_ratios", [None, [1, 3, 2]])
230+
@pytest.mark.parametrize("height_ratios", [None, [1, 2]])
226231
@check_figures_equal(extensions=['png'])
227-
def test_width_and_height_ratios_mosaic(fig_test, fig_ref):
232+
def test_width_and_height_ratios_mosaic(fig_test, fig_ref,
233+
height_ratios, width_ratios):
228234
mosaic_spec = [['A', 'B', 'B'], ['A', 'C', 'D']]
229-
fig_test.subplot_mosaic(mosaic_spec, height_ratios=[1, 2],
230-
width_ratios=[1, 3, 2])
235+
fig_test.subplot_mosaic(mosaic_spec, height_ratios=height_ratios,
236+
width_ratios=width_ratios)
231237
fig_ref.subplot_mosaic(mosaic_spec, gridspec_kw={
232-
'height_ratios': [1, 2],
233-
'width_ratios': [1, 3, 2]})
238+
'height_ratios': height_ratios,
239+
'width_ratios': width_ratios})
240+
241+
242+
def test_ratio_overlapping_kws():
243+
with pytest.raises(ValueError, match='height_ratios'):
244+
plt.subplots(2, 3, height_ratios=[1, 2],
245+
gridspec_kw={'height_ratios':[1,2]})
246+
with pytest.raises(ValueError, match='width_ratios'):
247+
plt.subplots(2, 3, width_ratios=[1, 2, 3],
248+
gridspec_kw={'width_ratios':[1, 2, 3]})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy