Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Replace axis_artist.AttributeCopier by normal inheritance. #13452

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 26, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 17, 2019

Note that the "default" provided to get_attribute_from_ref_artist would
previously never be triggered, as there is always a ref_artist present.

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

@tacaswell tacaswell added this to the v3.2.0 milestone Feb 27, 2019
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.

Is this whole ref_artist business still a thing then? If not get_ref_artist should also be deprecated in the derived classes and one should call the respective artist directly.

If so, I think it's reasonable to have some sort of pattern for it. Not necessarily full inheritance, but maybe a mixin, a decorator or function generator (Not thought this through - some of these may not be suitable).

@anntzer
Copy link
Contributor Author

anntzer commented Mar 5, 2019

one should call the respective artist directly.

That doesn't work because TickLabels relies on just overriding get_ref_artist and then using its parent class' get_color.

Not necessarily full inheritance, but maybe a mixin, a decorator or function generator

I had a quick try and it's a bit of a pain (especially for a one-off). Patches welcome, though.

@@ -211,14 +224,17 @@ def __init__(self, ticksize, tick_out=False, *, axis=None, **kwargs):
kwargs["markeredgewidth"] = "auto"

Line2D.__init__(self, [0.], [0.], **kwargs)
AttributeCopier.__init__(self, self._axis, klass=Line2D)
self._klass = Line2D # Only during the AttributeCopier deprecation.
self.set_snap(True)

def get_ref_artist(self):
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this private (_get_ref_artist)? I don't think ref artists need to be part of the public API.

Also please add a docstring such as:

Return an underlying artist, that actually defines the properties (e.g. color) of self.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly I wouldn't bother with the deprecation; it's not as if there's any plan to actually change that method.
Added the docstring.

Copy link
Member

@timhoffm timhoffm Mar 16, 2019

Choose a reason for hiding this comment

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

You've deprecated the whole AttributeCopier, which originally introduced get_ref_artist. It would only be consquent to remove get_ref_artist as well from the public API. This is foremost for cleaning up the public API. ref artists are an implementation detail that should not be publicly visible. Users should not be bothered with this (neither in the docs nor in parameter completion etc.). Future ability to change is only the weaker motivation.

@anntzer anntzer force-pushed the attributecopier branch 2 times, most recently from b93c81b to 810b092 Compare March 17, 2019 12:35
@anntzer
Copy link
Contributor Author

anntzer commented Mar 17, 2019

@timhoffm I figured out how to make the ref_artist delegation pattern work, so now it lives in AttributeCopier and the deprecation is much more limited.

@timhoffm
Copy link
Member

timhoffm commented Mar 17, 2019

Nice! That's a good pattern. 👍

The additional question is, do we need it as public API? If not I would still deprecate the whole AttributeCopier and use the pattern via a new _RefArtistMixin or _AttributeDelegateMixin class (which I also find to be better names than AttributeCopier.

@anntzer
Copy link
Contributor Author

anntzer commented Mar 17, 2019

Personally I find it a bit strange for a public class to inherit from a private class (for example, the actual docstring of get_ref_artist (a public API) would live in a private class.
If you really want to deprecate it, I would accept a PR from you to do so.

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.

@jklymak You've approved but there were significant changes after your review. Are you fine with the current state?

@anntzer Maybe I'll do a followup PR for a complete deprecation, but that can be discussed there.

Note that the "default" provided to get_attribute_from_ref_artist would
previously never be triggered, as there is always a ref_artist present.
@anntzer anntzer force-pushed the attributecopier branch from 46a5d94 to 62ff833 Compare June 5, 2019 13:48
@anntzer
Copy link
Contributor Author

anntzer commented Jun 5, 2019

rebased

@QuLogic QuLogic requested a review from jklymak July 25, 2019 06:02
@tacaswell tacaswell merged commit e62401f into matplotlib:master Aug 26, 2019
@anntzer anntzer deleted the attributecopier branch August 26, 2019 19: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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.