Skip to content

improve (matplotlib.widgets.Slider) doc + input validation #7687

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

Closed
sbowa opened this issue Dec 26, 2016 · 6 comments
Closed

improve (matplotlib.widgets.Slider) doc + input validation #7687

sbowa opened this issue Dec 26, 2016 · 6 comments
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Documentation
Milestone

Comments

@sbowa
Copy link

sbowa commented Dec 26, 2016

This minimal example throws an error (without crashing) when

  1. the slider is initialized with a slidermin/slidermax value
  2. the slider is moved with the mouse
    (the program does not crash, but the slider also does not respond)

Minimal example:

import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

fig, ax = plt.subplots()
slider = Slider(ax=ax, label='', valmin=0.0, valmax=24.0, valinit=15.0,
                slidermin=10.0, slidermax=20.0)
plt.show()

Fix follows.

sbowa added a commit to sbowa/matplotlib that referenced this issue Dec 26, 2016
@tacaswell
Copy link
Member

@sbowa Can you open a pull request with that change?

@tacaswell
Copy link
Member

This is not a bug, but a miss-use of the library. The slidermin and slidermax are either None or another slider instance (see http://matplotlib.org/api/widgets_api.html#matplotlib.widgets.Slider) not a float.

@tacaswell
Copy link
Member

The exact work to do on this:

  • update Slider.__init__ docstring to numpydoc (so it renders better)
  • add a duck-type validation of slidermin/slidermax (something like if sm is not None or hasattr(sm, 'val'): raise

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Dec 27, 2016
@tacaswell tacaswell added Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Documentation new-contributor-friendly labels Dec 27, 2016
@tacaswell tacaswell changed the title (matplotlib.widgets.Slider) slidermin/slidermax error improve (matplotlib.widgets.Slider) doc + input validation Dec 27, 2016
@sbowa
Copy link
Author

sbowa commented Dec 28, 2016

Thanks for clarification.

@tacaswell
Copy link
Member

@sbowa no problem! Sorry for not noticing what was going on sooner.

@tacaswell
Copy link
Member

Closed by #8134

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 Documentation
Projects
None yet
Development

No branches or pull requests

2 participants