8000 Improve Artist docstrings by timhoffm · Pull Request #11951 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Improve Artist docstrings #11951

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
Aug 28, 2018
Merged

Improve Artist docstrings #11951

merged 1 commit into from
Aug 28, 2018

Conversation

timhoffm
Copy link
Member

PR Summary

  • Adopting our current docstring conventions.
  • Improved a number of descriptions.
  • Reorder the methods in the overview artist_api.rst. There's nothing added or removed in this file.
    Motivation: Since the top-level grouping is semantically, I try to order related functions within the sections in a logical way. In particular I move getters and setters next to each other.

There's still a bit more to do within this module, but I think the PR is big enough for now.

@timhoffm timhoffm added this to the v3.1 milestone Aug 27, 2018
:meth:`remove_callback` later.
Parameters
----------
func : Callable[Artist]
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically that's Callable[[Artist], Any] (I think).

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted to just callback. In such cases, I will write the required signature as a type-annotated example in such cases.

IMO def func(artist: Artist) -> Any is easier to understand than Callable[[Artist], Any].


:meth:`add_callback`
For adding callbacks
Remove a callback based on its observer *id*.
Copy link
Contributor

Choose a reason for hiding this comment

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

oid, not id

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to "observer id" without markup. "observer oid" would be sort of double.

@@ -220,8 +223,8 @@ def axes(self, new_axes):
@property
def stale(self):
"""
If the artist is 'stale' and needs to be re-drawn for the output to
match the internal state of the artist.
A boolean flag indicating if the artist is 'stale' and needs to be
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I prefer the old version (after s/If/Whether).

Return a list of the child :class:`Artist`s this
:class:`Artist` contains.
"""
"""Return a list of the child `.Artist`\ s this `.Artist` contains."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be a raw string with no space after the backslash.


Parameters
----------
picker : callable
picker : Callable[Artist, MouseEvent]
Copy link
Contributor

Choose a reason for hiding this comment

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

See above. I would also not bother repeating the signature just below. (Or we can just decide to write type annotations in "signature" form as below; either way I don't think repeating the same info twice in slightly different formats really helps here.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Switching to just "callable" and giving an example signature below (see also comment above).


A 3-tuple with the following elements:

* `scale`: The amplitude of the wiggle perpendicular to the
- *scale*: The amplitude of the wiggle perpendicular to the
Copy link
Contributor

Choose a reason for hiding this comment

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

Unindent the list. Probably also remove the blank lines in between.

contained in self.

*match* can be
Recursively find all `.Artist` instances contained in self.
Copy link
Contributor
@anntzer anntzer Aug 27, 2018

Choose a reason for hiding this comment

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

in *self* perhaps, or in the artist (as above)

The result will only contain artists for which the function
returns *True*.
- A class instance: e.g., `.Line2D`. The result will only contain
artists of this class or it's subclasses (``isinstance`` check).
Copy link
Contributor

Choose a reason for hiding this comment

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

its

Copy link
Member
@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Small comment, but a big improvement so happy for this to be merged either way

registered callbacks.
Call all of the registered callbacks.

This function is triggered internally when a property changed.
8000 Copy link
Member

Choose a reason for hiding this comment

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

"property changed" > "property is changed"

@NelleV NelleV merged commit 3c0bd99 into matplotlib:master Aug 28, 2018
@NelleV
Copy link
Member
NelleV commented Aug 28, 2018

Thanks @timhoffm !

@timhoffm timhoffm deleted the doc-artist branch August 28, 2018 15:45
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.

4 participants
0