Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: by-pass creating a local class if backend has a Backend class #22380

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

Closed
wants to merge 1 commit into from

Conversation

tacaswell
Copy link
Member

PR Summary

Simplify using a backend that has a backend class. I think this is the next step down the path @anntzer started us on.

There is analogous code in mpl-gui at https://github.com/tacaswell/mpl-gui/blob/bc0cdc7bd58095039f124516cd6ca88611509513/mpl_gui/_manage_backend.py#L87-L109 .

It may be worth holding this PR until we sort out if there is anything else we want to hoist upstream from mpl_gui.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

This is implicitly tested, but might be worth pushing in some explicit tests of when the local backend does or does not get created.

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@anntzer
Copy link
Contributor

anntzer commented Feb 3, 2022

I guess we need to standardize on a name there, effectively saying "a module with a Foo global is a backend". I'm fine with calling that Backend, I just want to make sure we agree on the name.

OTOH, another approach (#18854) would be to move "everything" to the FigureCanvas class ("a module with a FigureCanvas global is a backend"). (Note, in particular, that this allows reusing the already preexisting inheritance relationship that exists between canvases.) Perhaps you can comment on that PR?

@tacaswell
Copy link
Member Author

I like #18854 a lot better. It gives you a path to from just a Figure walk your way up to building it a sibling in whatever scheme of canvas / manager / show / etc the user has put together.

I had thought about attaching the Backend object to FigureCanvas an friends, but then you can not re-use the classes between backends. Going the otherway and putting all of the parts on the FigureCanvas means with minimal sub-classing you can associate a custom manager to a given FigureCanvas.

Thinking a bit more about the toolbar discussion, I think having down-stream sub-class either the Manger or Toolbar classes is not a terrible pattern to suggest. We tend to think in terms of libraries and compos-ability (which makes sense given our interest in working at the library level!), but the cases where I have seen where there is significant toolbar customization have been domain specific applications (the buttons the added only made sense in a very narrow science context) where the lack of being able to compose with another packages modifications does not matter.

Closing in favor of #18854 where (as normal) @anntzer is a few steps ahead of me.

@tacaswell tacaswell closed this Feb 3, 2022
@tacaswell tacaswell modified the milestones: v3.7.0, unassigned Feb 3, 2022
@tacaswell tacaswell deleted the enh_backend_classes branch February 3, 2022 18:52
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.

2 participants