Skip to content
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

drawstyle accepts anything as default rather than raising #6143

Closed
madphysicist opened this issue Mar 11, 2016 · 3 comments
Closed

drawstyle accepts anything as default rather than raising #6143

madphysicist opened this issue Mar 11, 2016 · 3 comments
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Milestone

Comments

@madphysicist
Copy link
Contributor

Setup

matplotlib.__version__ = 1.5.1
matplotlib.__version__numpy__ = 1.6
Python 3.5.1, IPython 4.1.2 running under anaconda
OS: Red Hat 6.5

Matplotlib installed with conda install matplotlib.

Issue

Supplying invalid drawstyle parameter to plot (and possible others) does not raise an error. I would expect the following not to work, but it does:

>>> import matplotlib.pyplot as plt
>>> plt.plot(range(5), range(5), drawstyle='mwahahahahaha')

For contrast, trying the same thing with fillstyle raises the expected error:

>>> plt.plot(range(5), range(5), fillstyle='mwahahahahaha')
...
ValueError: Unrecognized fillstyle full left right bottom top none

Notes

The issue seems to be happening here:

if self._drawstyle != drawstyle:
. I would submit a PR, but I am pretty sure that adding something like

drawstyles = ('default', 'steps', 'steps-pre', 'steps-mid', 'steps-post')
if drawstyle not in drawstyles:
    raise ValueError(' '.join(('Unrecognized drawstyle',) + drawstyles))

would mess up something or another. If not, I would be glad to make the change.

To help us understand and resolve your issue please check that you have provided
the information below.

@tacaswell
Copy link
Member

That seems like a reasonable course of action. In the (near) future the plan is to use traitlets everywhere which will help with this sort of thing, but documenting what needs to be validated by code that validates them in probably a good thing.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Mar 11, 2016
@tacaswell
Copy link
Member

Most importantly, if you add tests it will make sure the traitlets do not cause any regressions.

@tacaswell tacaswell added the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Mar 11, 2016
@madphysicist
Copy link
Contributor Author

I just wasn't sure if there was additional parsing being done as for set_linestyle, which accepts both a linestyle and a drawstyle in the same string.

madphysicist added a commit to madphysicist/matplotlib that referenced this issue Mar 11, 2016
Added a check that forbids `drawstyle` keywords that are not listed in the documentation.
madphysicist added a commit to madphysicist/matplotlib that referenced this issue Mar 11, 2016
madphysicist added a commit to madphysicist/matplotlib that referenced this issue Mar 12, 2016
Added a check that forbids `drawstyle` keywords that are not listed in the documentation.
Added tests to mimic linestyle tests.
Added self to mailmap.
@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.1 (next point release) Mar 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Projects
None yet
Development

No branches or pull requests

2 participants