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

Skip to content

Parameterize test_fill_between and test_fill_betweenx #8729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 25 additions & 61 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,40 +847,40 @@ def test_polycollection_joinstyle():
ax.set_ybound(0, 3)


def test_fill_between_2d_x_input():
x = np.zeros((2, 2))
y1 = 3
y2 = 3

fig = plt.figure()
ax = fig.add_subplot(211)
with pytest.raises(ValueError):
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2)


def test_fill_between_2d_y1_input():
x = np.arange(0.0, 2, 0.02)
y1 = np.zeros((2, 2))
y2 = 3

@pytest.mark.parametrize(
'x, y1, y2', [
(np.zeros((2, 2)), 3, 3),
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
], ids=[
'2d_x_input',
'2d_y1_input',
'2d_y2_input'
]
)
def test_fill_between_input(x, y1, y2):
fig = plt.figure()
ax = fig.add_subplot(211)
with pytest.raises(ValueError):
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2)


def test_fill_between_2d_y2_input():
x = np.arange(0.0, 2, 0.02)
y1 = 3
y2 = np.zeros((2, 2))

@pytest.mark.parametrize(
'y, x1, x2', [
(np.zeros((2, 2)), 3, 3),
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
], ids=[
'2d_y_input',
'2d_x1_input',
'2d_x2_input'
]
)
def test_fill_betweenx_input(y, x1, x2):
fig = plt.figure()
ax = fig.add_subplot(211)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone got any idea why this line is here? Looks pointless to me...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is the line you meant to comment on? How else would you plot without an Axes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ I thought the previous line was plt.subplots (which I'm far too used too). Still not sure why it's called with 211 instead of 111, but doesn't make a difference either way.

with pytest.raises(ValueError):
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2)
ax.fill_betweenx(y, x1, x2)


@image_comparison(baseline_images=['fill_between_interpolate'],
Expand Down Expand Up @@ -4995,42 +4995,6 @@ def test_tick_param_label_rotation():
assert text.get_rotation() == 90


def test_fill_betweenx_2d_y_input():
y = np.zeros((2, 2))
x1 = 3
x2 = 3

fig = plt.figure()
ax = fig.add_subplot(211)
with pytest.raises(ValueError):
ax.plot(y, x1, y, x2, color='black')
ax.fill_betweenx(y, x1, x2)


def test_fill_betweenx_2d_x1_input():
y = np.arange(0.0, 2, 0.02)
x1 = np.zeros((2, 2))
x2 = 3

fig = plt.figure()
ax = fig.add_subplot(211)
with pytest.raises(ValueError):
ax.plot(y, x1, y, x2, color='black')
ax.fill_betweenx(y, x1, x2)


def test_fill_betweenx_2d_x2_input():
y = np.arange(0.0, 2, 0.02)
x1 = 3
x2 = np.zeros((2, 2))

fig = plt.figure()
ax = fig.add_subplot(211)
with pytest.raises(ValueError):
ax.plot(y, x1, y, x2, color='black')
ax.fill_betweenx(y, x1, x2)


@pytest.mark.style('default')
def test_fillbetween_cycle():
fig, ax = plt.subplots()
Expand Down