Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
TST: Backend switching API (don't merge)#11612
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
See changes documented in the API changes file.Some followup cleanup (of the now unused old machinery) will come as aseparate PR (left some "FIXME: Remove." comments).Changes to the build process (namely, getting rid of trying to detectthe default backend in setupext.py) will come as a separate PR.I inlined pylab_setup into switch_backend (and deprecated the oldversion of pylab_setup) because otherwise the typical call stack wouldbe `use()` -> `set rcParams['backend'] = ...` -> `switch_backend()` ->`pylab_setup()`, which is a bit of a mess; at least we can get rid ofone of the layers.
The selection logic is now described in the module's docstring. Theonly changes is that the QT_ENV_MAJOR_VERSION global, which wouldsometimes be defined (depending on the state of the import cache, theQT_API environment variable, and the requested backend) is never definedanymore.
The I am 50/50 on adding Similarly, storing the current backend in matplotlib/lib/matplotlib/__init__.py Lines 1380 to 1382 ine3042ab
I think I am on board with pushing people to I am 👍 on adding |
timhoffm commentedJul 10, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The changes are rather independent and could be introduced incrementally, if we are not sure about some of them:
A reasonable minimal start for 3.0 could be just to do 1. (and maybe 4.) - acknowledging that the original PRs#11581 and#11600 are tagged3.0 andrelease-critical. The other points seem to be more controversial and there is no need to rush it. |
try: | ||
switch_backend(candidate) | ||
except ImportError: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
probably need to do something if no backend is successfully imported.
cbook.warn_deprecated('3.0', | ||
"The rcParam 'backend' is deprecated. Use the rcParam " | ||
"'default_backends' to access the defaults. Use get_backend() " | ||
"to get the current backend.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
But then you need to store the current backend somewhere else and update the implementation of get_backend accordingly.
@timhoffm I agree with your suggestions above. OTOH for now we want to get backend switching in, and the existing rcParam stuffing, while suboptimal, is the existing API. So for 3.0 I think we decided to move along w/@anntzer PR (plus or minus any review changes) and then we can re-open the deprecation/API refinement for 3.1 (due December-ish). |
Superseeded by#11600 |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
This PR creates a possible API for backend switching. The API is laid out in thelast commit. Previous commits are from#11600 and only contain the actual switching logic.
The code is not fully tested. It's main purpose is to give an idea how the following API can be implemented:
rcParams['default_backends']
that accepts a list of possible backends to try out.rcParams['backend']
is deprecated.rcParams['backend'] is deprecated. Users should use
rcParams['default_backends']or
get_backend()` depeding on their needs.matplotlib.use()
is deprecated in favor ofset_backend()
-- this is independent of the other API changes but adds to consistency.Typical use-cases:
Setting the default backend
new API:
current API (deprecated):
Setting the current backend
new API:
current API (deprecated):
Querying the current backend:
new API:
current API (deprecated):