8000 Deduplicate implementations of FooNorm.autoscale{,_None} by anntzer · Pull Request #12309 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Deduplicate implementations of FooNorm.autoscale{,_None} #12309

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
Sep 28, 2018

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Sep 27, 2018

... and some docstring cleanups.

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

@anntzer anntzer added this to the v3.1 milestone Sep 27, 2018
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.

Good, except for some style issues.

A = np.ma.masked_less_equal(A, 0, copy=False)
self.vmin = np.ma.min(A)
self.vmax = np.ma.max(A)
super().autoscale(np.ma.masked_less_equal(A, 0, copy=False))
Copy link
Member

Choose a reason for hiding this comment

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

# docstring inherited 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, then decided against because here all methods are in the same file and the overrides are quite short (one or two lines), so I thought things were clear enough as they are. If you really want it let me know (or push it yourself, either way).

Copy link
Member

Choose a reason for hiding this comment

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

I would still do it. It's a statement of intent. Without that, someone will be tempted in the future to add a docstring.

Also, let's just make it a general general rule. Every public method should have either a docstring or a # docstring inherited comment. If we then encounter a method without that, it's immediately clear that nobody has thought about the documentation so far.

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 (x4)

self.vmin = A.min()
if self.vmax is None and A.size:
self.vmax = A.max()
super().autoscale_None(np.ma.masked_less_equal(A, 0, copy=False))
Copy link
Member

Choose a reason for hiding this comment

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

# docstring inherited

Dummy replacement for Normalize, for the case where we
want to use indices directly in a
:class:`~matplotlib.cm.ScalarMappable` .
Dummy replacement for Normalize, for the case where we want to use indices
Copy link
Member

Choose a reason for hiding this comment

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

would be nice to link `Normalize`

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

"""
self.vmin = np.ma.min(A)
self.vmax = np.ma.max(A)
super().autoscale(A)
Copy link
Member

Choose a reason for hiding this comment

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

# docstring inherited

self.vmin = A.min()
if self.vmax is None and A.size:
self.vmax = A.max()
super().autoscale_None(A)
Copy link
Member

Choose a reason for hiding this comment

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

# docstring inherited

@anntzer anntzer force-pushed the normalize-autoscale branch from c002bd6 to 888a888 Compare September 28, 2018 05:40
@anntzer anntzer force-pushed the normalize-autoscale branch from 888a888 to a686376 Compare September 28, 2018 07:38
@timhoffm timhoffm merged commit 6eee9ce into matplotlib:master Sep 28, 2018
@anntzer anntzer deleted the normalize-autoscale branch September 28, 2018 09:17
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.

3 participants
0