Skip to content

Deduplicate methods shared between Container and Artist. #13702

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

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 18, 2019

Container does not inherit from Artist, but still shares some of its
methods. Instead of duplicating the implementation, just directly use
the Artist methods.

We could also move these shared methods to a mixin that both Artist and
Container inherit, but that would just confuse the matters IMO.

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

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.

Though maybe worth doing a rebase on to current master before merging to double check this is still fine

@jklymak
Copy link
Member

jklymak commented Aug 14, 2019

w/o checking, does this have any effect on the docs?

@tacaswell tacaswell added this to the v3.2.0 milestone Aug 14, 2019
Container does not inherit from Artist, but still shares some of its
methods.  Instead of duplicating the implementation, just directly use
the Artist methods.

We could also move these shared methods to a mixin that both Artist and
Container inherit, but that would just confuse the matters IMO.
@anntzer
Copy link
Contributor Author

anntzer commented Aug 16, 2019

@timhoffm
Copy link
Member

timhoffm commented Aug 16, 2019

Maybe it‘s my strongly typed OOP heritage, but shouldn‘t these methods go into a common base class, maybe a mixin? This feels a bit hacky: Container has now a non-obvious dependency on Artist.

@anntzer
Copy link
Contributor Author

anntzer commented Aug 16, 2019

I decided against this making a common base class because it makes things more confusing, not less, IMO (if the base class is private, we have the same problem as with _AxesBase which is that some public methods are defined in a private class; if the base class is public it's kind of an ad-hoc beast (the methods provided don't have much in common except, well, being shared by Artist and Container).
It's not a very strong feeling so I can add a base class if you really prefer that. You get to pick the name :)

@tacaswell
Copy link
Member

I don't disagree with @timhoffm , but container is already a bit of an oddity in terms of what it is and how it behaves so I think this is better than having duplicated code.

@efiring efiring merged commit 47e3aa5 into matplotlib:master Sep 3, 2019
@anntzer anntzer deleted the container branch September 3, 2019 19:53
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.

6 participants