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.
Changes fromall commits
ffbb62c
d047f52
901477c
c0bae18
eec27b0
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -803,7 +803,9 @@ def gen_candidates(): | ||
# rcParams deprecated and automatically mapped to another key. | ||
# Values are tuples of (version, new_name, f_old2new, f_new2old). | ||
_deprecated_map = { | ||
'backend': (3.0, 'default_backends', lambda x: [x], lambda x: x[0]) | ||
} | ||
# rcParams deprecated; some can manually be mapped to another key. | ||
# Values are tuples of (version, new_name_or_None). | ||
@@ -909,8 +911,17 @@ def __setitem__(self, key, val): | ||
'%s is not a valid rc parameter. See rcParams.keys() for a ' | ||
'list of valid parameters.' % (key,)) | ||
def _set_current_backend(self, backend): | ||
dict.__setitem__(self, 'backend', backend) | ||
def __getitem__(self, key): | ||
if key == 'backend': | ||
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 commentThe 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. | ||
return dict.__getitem__(self, backend) | ||
elif key in _deprecated_map: | ||
version, alt_key, alt_val, inverse_alt = _deprecated_map[key] | ||
cbook.warn_deprecated( | ||
version, key, obj_type="rcparam", alternative=alt_key) | ||
@@ -1318,6 +1329,7 @@ def __exit__(self, exc_type, exc_value, exc_tb): | ||
dict.update(rcParams, self._orig) | ||
# FIXME: Remove. | ||
_use_error_msg = """ | ||
This call to matplotlib.use() has no effect because the backend has already | ||
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot, | ||
@@ -1327,65 +1339,30 @@ def __exit__(self, exc_type, exc_value, exc_tb): | ||
{tb} | ||
""" | ||
def set_backend(arg, warn=True, force=False): | ||
""" | ||
Set the Matplotlib backend. | ||
The argument is case-insensitive. Switching to an interactive backend is | ||
only safe if no event loop for another interactive backend has started. | ||
Switching to and from non-interactive backends is safe. | ||
To find out which backend is currently set, see `matplotlib.get_backend`. | ||
Parameters | ||
---------- | ||
arg : str | ||
The name of the backend to use. | ||
""" | ||
# We want to keep 'use(...); rcdefaults()' working, which means that | ||
# use(...) needs to force the default backend too. | ||
rcParams["backend"] = \ | ||
rcParamsDefault["backend"] = rcParamsOrig["backend"] = arg | ||
@cbook.deprecated('3.0', alternative='matplotlib.set_backend') | ||
def use(arg, warn=True, force=False): | ||
set_backend(arg, warn, force) | ||
if os.environ.get('MPLBACKEND'): | ||
Uh oh!
There was an error while loading.Please reload this page.