8000 Numpydocify RectangleSelector docstring. by anntzer · Pull Request #17474 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Numpydocify RectangleSelector docstring. #17474

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 1 commit into from
May 23, 2020
Merged

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented May 21, 2020
  • The given signature for onselect was wrong -- it is called with the
    start and end events as arguments.
  • Changed the default of minspanx, minspany to 0 -- it is easier to
    document. None is kept as undocumented backcompat; deprecating None
    would also beed to cover assignment to the minspanx/y attributes
    (probably using a property, yada yada).
  • marker_props is currently ignored, but let's not deprecate it as it
    would actually make sense to support it (consistently with
    PolygonSelector -- which names it markerprops but heh...).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@@ -1930,61 +1930,59 @@ def toggle_selector(event):
_shape_klass = Rectangle

def __init__(self, ax, onselect, drawtype='box',
minspanx=None, minspany=None, useblit=False,
Copy link
Member

Choose a reason for hiding this comment

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

There's a check for self.minspanx is not None, so I'm not sure if this should change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's fine, if it's None then the test spanx < minspanx is skipped, but if it's zero then spanx < minspanx is never true, so the end result is the same.

The parent axes for the widget.
onselect : function
When a selection is made, the selector is cleared and *onselect*
is called with two arguments: the button press event and button
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing it in our documentation guide, but don't we have some more standard way of defining these callback signatures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

may be nice, but I don't know?

backend).
lineprops : dict, default: \
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
Properties with which the line is drawn.
Copy link
Member

Choose a reason for hiding this comment

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

Only used if using drawtype='line', i.e., not for edges of the rectangle, so I think that should be called out here.

8000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

Properties with which the line is drawn.
rectprops : dict, default: \
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
Properties with which the rectangle is drawn.
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, only for drawtype='box'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

spancoords : {"data", "pixels"}
Whether to interpret *minspanx* and *minspany* in data or in pixel
coordinates.
button : `.MouseButton`, list of `.MouseButton` or None, 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.

Suggested change
button : `.MouseButton`, list of `.MouseButton` or None, default: None
button : `.MouseButton`, list of `.MouseButton`, or None, default: None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

Comment on lines 1966 to 1984
button : `.MouseButton`, list of `.MouseButton`, or None, default: None
Button(s) that trigger rectangle selection; None means "any
button".
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
button : `.MouseButton`, list of `.MouseButton`, or None, default: None
Button(s) that trigger rectangle selection; None means "any
button".
button : `.MouseButton` or list of `.MouseButton`, default: any button
The mouse button(s) that control the selection.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about that, as not mentioning None might imply that it means no buttons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree with @QuLogic

Copy link
Member

Choose a reason for hiding this comment

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

I argue that in this context None is only used as "parameter not specified" = "use the default.

From https://matplotlib.org/devdocs/devel/documenting_mpl.html#default-values:

If None is only used as a sentinel value for "parameter not specified", do not document it as the default. Depending on the context, give the actual default, or mark the parameter as optional if not specifying has no particular effect.

I don't think users should ever explicitly pass None, which as @QuLogic indicated could have a totally different semantic from what it actually does. Therefore I wouldn't even bother documenting it.

That said, it would be much clearer if the value was 'all' instead of None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's plenty of places where None means "all buttons", we're basically stuck with it. I undocumented None.

- The given signature for `onselect` was wrong -- it is called with the
  start and end events as arguments.
- Changed the default of `minspanx`, `minspany` to 0 -- it is easier to
  document.  None is kept as undocumented backcompat; deprecating None
  would also beed to cover assignment to the `minspanx/y` attributes
  (probably using a property, yada yada).
- `marker_props` is currently ignored, but let's not deprecate it as it
  would actually make sense to support it (consistently with
  PolygonSelector -- which names it `markerprops` but heh...).
Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

I‘m giving @QuLogic a day or so for commenting on the buttons default before merging.

@timhoffm timhoffm added this to the v3.3.0 milestone May 23, 2020
@timhoffm timhoffm merged commit 16df024 into matplotlib:master May 23, 2020
@anntzer anntzer deleted the rs branch May 23, 2020 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0