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

Skip to content

Commit e702cd8

Browse files
committed
Update exception string to use %r for formatting
1 parent 72f6359 commit e702cd8

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4777,8 +4777,8 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
47774777

47784778
for name, array in [('x', x), ('y1', y1), ('y2', y2)]:
47794779
if array.ndim > 1:
4780-
raise ValueError('Input passed into argument "' + name +
4781-
'" is not 1-dimensional.')
4780+
raise ValueError('Input passed into argument "%r"' % name +
4781+
'is not 1-dimensional.')
47824782

47834783
if y1.ndim == 0:
47844784
y1 = np.ones_like(x) * y1
@@ -4941,10 +4941,10 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
49414941
x1 = ma.masked_invalid(self.convert_xunits(x1))
49424942
x2 = ma.masked_invalid(self.convert_xunits(x2))
49434943

4944-
for array in [('x', x), ('y1', y1), ('y2', y2)]:
4945-
if array[1].ndim > 1:
4946-
raise ValueError('Input passed into argument "' + array[0] +
4947-
'" is not 1-dimensional.')
4944+
for name, array in [('y', y), ('x1', x1), ('x2', x2)]:
4945+
if array.ndim > 1:
4946+
raise ValueError('Input passed into argument "%r"' % name +
4947+
'is not 1-dimensional.')
49484948

49494949
if x1.ndim == 0:
49504950
x1 = np.ones_like(y) * x1

lib/matplotlib/tests/test_axes.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,39 +725,42 @@ def test_polycollection_joinstyle():
725725
ax.set_ybound(0, 3)
726726

727727

728+
@cleanup
728729
def test_fill_between_2d_x_input():
729730
x = np.zeros((2, 2))
730731
y1 = 3
731732
y2 = 3
732733

733734
fig = plt.figure()
734735
ax = fig.add_subplot(211)
735-
ax.plot(x, y1, x, y2, color='black')
736736
with pytest.raises(ValueError):
737+
ax.plot(x, y1, x, y2, color='black')
737738
ax.fill_between(x, y1, y2)
738739

739740

741+
@cleanup
740742
def test_fill_between_2d_y1_input():
741743
x = np.arange(0.0, 2, 0.02)
742744
y1 = np.zeros((2, 2))
743745
y2 = 3
744746

745747
fig = plt.figure()
746748
ax = fig.add_subplot(211)
747-
ax.plot(x, y1, x, y2, color='black')
748749
with pytest.raises(ValueError):
750+
ax.plot(x, y1, x, y2, color='black')
749751
ax.fill_between(x, y1, y2)
750752

751753

754+
@cleanup
752755
def test_fill_between_2d_y2_input():
753756
x = np.arange(0.0, 2, 0.02)
754757
y1 = 3
755758
y2 = np.zeros((2, 2))
756759

757760
fig = plt.figure()
758761
ax = fig.add_subplot(211)
759-
ax.plot(x, y1, x, y2, color='black')
760762
with pytest.raises(ValueError):
763+
ax.plot(x, y1, x, y2, color='black')
761764
ax.fill_between(x, y1, y2)
762765

763766

@@ -4837,39 +4840,42 @@ def test_tick_param_label_rotation():
48374840
assert text.get_rotation() == 90
48384841

48394842

4843+
@cleanup
48404844
def test_fill_betweenx_2d_y_input():
48414845
y = np.zeros((2, 2))
48424846
x1 = 3
48434847
x2 = 3
48444848

48454849
fig = plt.figure()
48464850
ax = fig.add_subplot(211)
4847-
ax.plot(y, x1, y, x2, color='black')
48484851
with pytest.raises(ValueError):
4852+
ax.plot(y, x1, y, x2, color='black')
48494853
ax.fill_betweenx(y, x1, x2)
48504854

48514855

4856+
@cleanup
48524857
def test_fill_betweenx_2d_x1_input():
48534858
y = np.arange(0.0, 2, 0.02)
48544859
x1 = np.zeros((2, 2))
48554860
x2 = 3
48564861

48574862
fig = plt.figure()
48584863
ax = fig.add_subplot(211)
4859-
ax.plot(y, x1, y, x2, color='black')
48604864
with pytest.raises(ValueError):
4865+
ax.plot(y, x1, y, x2, color='black')
48614866
ax.fill_betweenx(y, x1, x2)
48624867

48634868

4869+
@cleanup
48644870
def test_fill_betweenx_2d_x2_input():
48654871
y = np.arange(0.0, 2, 0.02)
48664872
x1 = 3
48674873
x2 = np.zeros((2, 2))
48684874

48694875
fig = plt.figure()
48704876
ax = fig.add_subplot(211)
4871-
ax.plot(y, x1, y, x2, color='black')
48724877
with pytest.raises(ValueError):
4878+
ax.plot(y, x1, y, x2, color='black')
48734879
ax.fill_betweenx(y, x1, x2)
48744880

48754881

0 commit comments

Comments
 (0)