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

Fix a bunch of doc/comment typos in patches.py. #11299

Merged
merged 1 commit into from
May 24, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 24, 2018

Also some small code cleanups there. The alias getters are already
defined by cbook._define_aliases.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 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

@@ -1906,6 +1905,13 @@ def register(klass, name, style):
klass._style_list[name] = style


def _register_style(style_list, cls=None, *, name=None):
Copy link
Member

@jklymak jklymak May 24, 2018

Choose a reason for hiding this comment

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

This needs a comment describing what it does and why.

The list being filled before was called _style_list. I'm not sure what that list does, but you've dropped the underscore below. EDIT: OK, I see, style_list is the argument. Sorry. But then really not sure what this gets us since we have to pass the list in as an argument.

Is there an actual advantage to having this a decorator versus filling the global?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my view it's more or less the same reason why

@property
def foo(self): ...

is better than

def foo(self): ...
foo = property(foo)

i.e. you immediately declare one of the most important things you're going to do with the newly declared function/class (in our cases, stash it in the style dict).

Added a docstring.

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 always uncertain if a registering decorator a good idea. It makes the registration more intransparent. On the other hand it can be more semantic. In the present case I tend to think it's an improvement.

What I don't like is the _style_list param. At best we could get rid of it. However, I don't think that's possible (there is no such thing a decorator owned by the class, that can access the class variable _style_list. At least, can we rename the _style_list class variables to _styles or even better _style_classes.

Copy link
Member

Choose a reason for hiding this comment

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

Uh, oh. style_list isn't even a list. 👿

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re: the param: yes, we could do some stack walking, but that seems totally overkill.

While _style_list is indeed a terrible name, and technically private, it is actually exposed in the custom_boxstyle02.py example, and should be cleaned up from there first (as in, we either need to not support custom styles, or have a public API to do so), which I'll leave to a separate PR.

The coordinates of the vertices as a Nx2
ndarray or iterable of pairs.
xy : Nx2 array-like
The coordinates of the vertices as a Nx2 array-like.
Copy link
Member

Choose a reason for hiding this comment

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

could leave out "as a ..." (already given in the type).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -1906,6 +1905,13 @@ def register(klass, name, style):
klass._style_list[name] = style


def _register_style(style_list, cls=None, *, name=None):
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 always uncertain if a registering decorator a good idea. It makes the registration more intransparent. On the other hand it can be more semantic. In the present case I tend to think it's an improvement.

What I don't like is the _style_list param. At best we could get rid of it. However, I don't think that's possible (there is no such thing a decorator owned by the class, that can access the class variable _style_list. At least, can we rename the _style_list class variables to _styles or even better _style_classes.

Also some small code cleanups there.  The alias getters are already
defined by cbook._define_aliases.
@jklymak jklymak merged commit df8a02b into matplotlib:master May 24, 2018
@anntzer anntzer deleted the patchespy branch May 24, 2018 23:16
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request May 28, 2018
anntzer added a commit that referenced this pull request May 28, 2018
@QuLogic QuLogic added this to the v3.0.0 milestone Nov 27, 2018
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.

None yet

4 participants