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

Skip to content

Commit e738593

Browse files
committed
Merge pull request #6145 from madphysicist/patch-1
MNT: fail earlier on unknown draw_style Conflicts: .mailmap
1 parent 57fa73f commit e738593

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Jens Hedegaard Nielsen <[email protected]> Jens H Nielsen <jenshnielsen@gma
1919
Jens Hedegaard Nielsen <[email protected]> Jens H. Nielsen <[email protected]>
2020
Jens Hedegaard Nielsen <[email protected]> Jens H. Nielsen <[email protected]>
2121
John Hunter <[email protected]> jdh2358 <[email protected]>
22+
Joseph Fox-Rabinovitz <[email protected]> Mad Physicist <[email protected]>
2223
Jouni K. Seppänen <[email protected]> Jouni K. Seppänen <[email protected]>
2324
Julien Schueller <[email protected]> jschueller <[email protected]>
2425
Julien Schueller <[email protected]> Julien Schueller <[email protected]>

lib/matplotlib/lines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,9 @@ def set_drawstyle(self, drawstyle):
986986
ACCEPTS: ['default' | 'steps' | 'steps-pre' | 'steps-mid' |
987987
'steps-post']
988988
"""
989+
if drawstyle not in self.drawStyles:
990+
raise ValueError('Unrecognized drawstyle ' +
991+
' '.join(self.drawStyleKeys))
989992
if self._drawstyle != drawstyle:
990993
self.stale = True
991994
self._drawstyle = drawstyle

lib/matplotlib/tests/test_lines.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,29 @@ def test_valid_linestyles():
118118
line.set_linestyle('aardvark')
119119

120120

121+
@cleanup
122+
def test_drawstyle_variants():
123+
fig = plt.figure()
124+
ax = fig.add_subplot(1, 1, 1)
125+
for ds in ("default", "steps-mid", "steps-pre", "steps-post",
126+
"steps"):
127+
ax.plot(range(10), drawstyle=ds)
128+
129+
fig.canvas.draw()
130+
assert True
131+
132+
133+
@cleanup
134+
def test_valid_drawstyles():
135+
if sys.version_info[:2] < (2, 7):
136+
raise nose.SkipTest("assert_raises as context manager "
137+
"not supported with Python < 2.7")
138+
139+
line = mlines.Line2D([], [])
140+
with assert_raises(ValueError):
141+
line.set_drawstyle('foobar')
142+
143+
121144
@image_comparison(baseline_images=['line_collection_dashes'], remove_text=True)
122145
def test_set_line_coll_dash_image():
123146
fig = plt.figure()

0 commit comments

Comments
 (0)