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

Skip to content

Commit f76a010

Browse files
committed
Parameterize test_fill_between and test_fill_betweenx
1 parent 6da2b8c commit f76a010

File tree

1 file changed

+17
-61
lines changed

1 file changed

+17
-61
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 17 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -847,40 +847,32 @@ def test_polycollection_joinstyle():
847847
ax.set_ybound(0, 3)
848848

849849

850-
def test_fill_between_2d_x_input():
851-
x = np.zeros((2, 2))
852-
y1 = 3
853-
y2 = 3
854-
855-
fig = plt.figure()
856-
ax = fig.add_subplot(211)
857-
with pytest.raises(ValueError):
858-
ax.plot(x, y1, x, y2, color='black')
859-
ax.fill_between(x, y1, y2)
860-
861-
862-
def test_fill_between_2d_y1_input():
863-
x = np.arange(0.0, 2, 0.02)
864-
y1 = np.zeros((2, 2))
865-
y2 = 3
866-
850+
@pytest.mark.parametrize(
851+
'x, y1, y2', [
852+
(np.zeros((2, 2)), 3, 3),
853+
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
854+
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
855+
]
856+
)
857+
def test_fill_between_input(x, y1, y2):
867858
fig = plt.figure()
868859
ax = fig.add_subplot(211)
869860
with pytest.raises(ValueError):
870-
ax.plot(x, y1, x, y2, color='black')
871861
ax.fill_between(x, y1, y2)
872862

873863

874-
def test_fill_between_2d_y2_input():
875-
x = np.arange(0.0, 2, 0.02)
876-
y1 = 3
877-
y2 = np.zeros((2, 2))
878-
864+
@pytest.mark.parametrize(
865+
'y, x1, x2', [
866+
(np.zeros((2, 2)), 3, 3),
867+
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
868+
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
869+
]
870+
)
871+
def test_fill_betweenx_input(y, x1, x2):
879872
fig = plt.figure()
880873
ax = fig.add_subplot(211)
881874
with pytest.raises(ValueError):
882-
ax.plot(x, y1, x, y2, color='black')
883-
ax.fill_between(x, y1, y2)
875+
ax.fill_betweenx(y, x1, x2)
884876

885877

886878
@image_comparison(baseline_images=['fill_between_interpolate'],
@@ -4995,42 +4987,6 @@ def test_tick_param_label_rotation():
49954987
assert text.get_rotation() == 90
49964988

49974989

4998-
def test_fill_betweenx_2d_y_input():
4999-
y = np.zeros((2, 2))
5000-
x1 = 3
5001-
x2 = 3
5002-
5003-
fig = plt.figure()
5004-
ax = fig.add_subplot(211)
5005-
with pytest.raises(ValueError):
5006-
ax.plot(y, x1, y, x2, color='black')
5007-
ax.fill_betweenx(y, x1, x2)
5008-
5009-
5010-
def test_fill_betweenx_2d_x1_input():
5011-
y = np.arange(0.0, 2, 0.02)
5012-
x1 = np.zeros((2, 2))
5013-
x2 = 3
5014-
5015-
fig = plt.figure()
5016-
ax = fig.add_subplot(211)
5017-
with pytest.raises(ValueError):
5018-
ax.plot(y, x1, y, x2, color='black')
5019-
ax.fill_betweenx(y, x1, x2)
5020-
5021-
5022-
def test_fill_betweenx_2d_x2_input():
5023-
y = np.arange(0.0, 2, 0.02)
5024-
x1 = 3
5025-
x2 = np.zeros((2, 2))
5026-
5027-
fig = plt.figure()
5028-
ax = fig.add_subplot(211)
5029-
with pytest.raises(ValueError):
5030-
ax.plot(y, x1, y, x2, color='black')
5031-
ax.fill_betweenx(y, x1, x2)
5032-
5033-
50344990
@pytest.mark.style('default')
50354991
def test_fillbetween_cycle():
50364992
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)