Skip to content

Update Slider docs and type check slidermin and slidermax. #8134

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

Merged
merged 10 commits into from
Feb 25, 2017

Conversation

heathhenley
Copy link
Contributor

@heathhenley heathhenley commented Feb 23, 2017

This addresses #7687.

  • I tried to improve the doc strings of the widgets.slider class using numpydoc format. Let me know if it should be handled differently or I missed something. I built the docs and it rendered cleaner than previously using the current version.

  • Raises a ValueError if the slidermin or slidermax objects are not a compatible type (None or hasattr( 'val')).

  • Adds a test to make sure exception is raised in appropriate cases.

As I was testing this I noticed that the initial value can be outside of the bounds, and it will not be updated until _update gets called. To correct this I wrapped the statements that ensure the value is within the provided bounds into a function and called it in the the constructor. Currently there is no validation on the bounds, but I would be willing to add that if you think it will help.


Notes
----------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picky thing, too many -- here, should be same length as title.

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional on fixing the docstring formatting.

@tacaswell
Copy link
Member

While you are working on this exercising all of the branches of the validation method would be good, but not worth holding this PR up over.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Feb 23, 2017
@heathhenley
Copy link
Contributor Author

Thanks @tacaswell. I addressed your comments in the recent commits. Let me know if I should squash some commits and rebase on master pre-merge.

Do not allow the current slider to have a value less than
`slidermin`
`slidermin.val`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slidermin.val? Is that some sort of special numpydoc thing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just saying it looks at the attribute I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think I see what is going on here. This needs to be clearer. Perhaps, "Do not allow the slider to have a value less than the value of the other Slider slidermin."

@tacaswell
Copy link
Member

Fine as is, rebase/squash if you want (I do it most when I am embarrassed about a mistake I committed ;) ).


dragging : bool, optional
If True the slider can be dragged by the mouse.
Default: True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to do special formatting for things like True and None?

-----
Additional kwargs are passed on to ``self.poly`` which is the
:class:`matplotlib.patches.Rectangle` that draws the slider
knob. See the :class:`matplotlib.patches.Rectangle` documentation for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put a tilda before the matplotlib.patches.Rectangle, then the rendered docs will only have Rectangle, which makes things easier to read.

Additional kwargs are passed on to ``self.poly`` which is the
:class:`matplotlib.patches.Rectangle` that draws the slider
knob. See the :class:`matplotlib.patches.Rectangle` documentation for
valid property names (e.g., *facecolor*, *edgecolor*, *alpha*, ...).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for ellipses when it is already "e.g.".

if not self.closedmax:
return
val = self.slidermax.val
self.set_val(val)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would rather that this method returns the value. It can then be up to the caller what to do with it. Might make it more portable with the planned traitlets work.

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from my minor comments on docstring formatting, this looks good.

If you prefer, I am happy fixing those just before merging.

less than *slidermax*

*dragging* : allow for mouse dragging on slider
Create a slider from *valmin* to *valmax* in axes *ax*. For the slider to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the "*" formatting?

The slider label
valinit : float, optional
The slider initial position.
Default: 0.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the default on the line that defines the parameter?
(note that it is currently not indented properly).

Used to format the slider value, fprint format string
valfmt : str, optional
Used to format the slider value, fprint format string.
Default: '%1.2f'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Can you add the default on the line that defines the parameter?)

Indicate whether the slider interval is closed on the bottom
closedmin : bool, optional
Indicate whether the slider interval is closed on the bottom.
Default: True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Can you add the default on the line that defines the parameter?)

Indicate whether the slider interval is closed on the top
closedmax : bool, optional
Indicate whether the slider interval is closed on the top.
Default: True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Can you add the default on the line that defines the parameter?)

Do not allow the current slider to have a value less than
`slidermin`
the value of the Slider `slidermin`.
Default: None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Can you add the default on the line that defines the parameter?)

`slidermax`

the value of the Slider `slidermax`.
Default: None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Can you add the default on the line that defines the parameter?)

if the slider can be dragged by the mouse
dragging : bool, optional
If True the slider can be dragged by the mouse.
Default: True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Can you add the default on the line that defines the parameter?)

Additional kwargs are passed on to ``self.poly`` which is the
:class:`~matplotlib.patches.Rectangle` that draws the slider
knob. See the :class:`~matplotlib.patches.Rectangle` documentation for
valid property names (e.g., *facecolor*, *edgecolor*, *alpha*).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the "*"?

self.valmin = valmin
self.valmax = valmax
valinit = self._value_in_bounds(valinit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@heathhenley
Copy link
Contributor Author

Thanks @NelleV, I made the changes you suggested where it was possible to fit the default listing on the same line. Let me know if there is anything else, I'd be happy to squash this down for you guys before merging especially all the nits/lints.

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed some minor nitpicks. It looks good to me.
👍

thanks a lot for the work on this PR @heath730 !

@NelleV NelleV changed the title Update Slider docs and type check slidermin and slidermax. [MRG+2] Update Slider docs and type check slidermin and slidermax. Feb 24, 2017
@heathhenley
Copy link
Contributor Author

Thanks! Going squash a couple of the doc commits and push once more.

@NelleV NelleV merged commit c3e65f1 into matplotlib:master Feb 25, 2017
@NelleV
Copy link
Member

NelleV commented Feb 25, 2017

Thanks @heath730 !

@QuLogic QuLogic changed the title [MRG+2] Update Slider docs and type check slidermin and slidermax. Update Slider docs and type check slidermin and slidermax. Feb 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants