Skip to content

Commit

Permalink
Merge pull request #6145 from madphysicist/patch-1
Browse files Browse the repository at this point in the history
MNT: fail earlier on unknown draw_style
  • Loading branch information
tacaswell committed Mar 13, 2016
2 parents 668bd02 + 9265aa0 commit 6a57084
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions .mailmap
Expand Up @@ -27,6 +27,7 @@ Jens Hedegaard Nielsen <jenshnielsen@gmail.com> <jens.nielsen@ucl.ac.uk>
John Hunter <jdh2358@gmail.com>
Jorrit Wronski <jowr@mek.dtu.dk>
Jouni K. Seppänen <jks@iki.fi>
Joseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com> Mad Physicist <madphysicist@users.noreply.github.com>
Julien Schueller <julien.schueller@gmail.com> <schueller@porsche-l64.phimeca.lan>
Julien Schueller <julien.schueller@gmail.com> <schueller@bx-l64.phimeca.lan>
Kevin Davies <kdavies4@gmail.com> <daviesk24@yahoo.com>
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/lines.py
Expand Up @@ -985,6 +985,9 @@ def set_drawstyle(self, drawstyle):
ACCEPTS: ['default' | 'steps' | 'steps-pre' | 'steps-mid' |
'steps-post']
"""
if drawstyle not in self.drawStyles:
raise ValueError('Unrecognized drawstyle ' +
' '.join(self.drawStyleKeys))
if self._drawstyle != drawstyle:
self.stale = True
self._drawstyle = drawstyle
Expand Down
23 changes: 23 additions & 0 deletions lib/matplotlib/tests/test_lines.py
Expand Up @@ -118,6 +118,29 @@ def test_valid_linestyles():
line.set_linestyle('aardvark')


@cleanup
def test_drawstyle_variants():
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
for ds in ("default", "steps-mid", "steps-pre", "steps-post",
"steps"):
ax.plot(range(10), drawstyle=ds)

fig.canvas.draw()
assert True


@cleanup
def test_valid_drawstyles():
if sys.version_info[:2] < (2, 7):
raise nose.SkipTest("assert_raises as context manager "
"not supported with Python < 2.7")

line = mlines.Line2D([], [])
with assert_raises(ValueError):
line.set_drawstyle('foobar')


@image_comparison(baseline_images=['line_collection_dashes'], remove_text=True)
def test_set_line_coll_dash_image():
fig = plt.figure()
Expand Down

0 comments on commit 6a57084

Please sign in to comment.