FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

MNT: Deprecate rcParams._get("backend") by timhoffm · Pull Request #30963 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/deprecations/30963-TH.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
``rcParams._get("backend")``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``rcParams._get("backend")`` is deprecated. Instead, use the public API
``matplotlib.get_backend(auto_select=False)`` to retrieve the current
backend without triggering backend resolution. This API is available since
Matplotlib 3.10.
26 changes: 14 additions & 12 deletions lib/matplotlib/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,14 @@ def _get(self, key):

:meta public:
"""
if key == "backend":
_api.warn_deprecated(
"rcParams._get('backend') is deprecated since Matplotlib 3.11. "
"Use matplotlib.get_backend(auto_select=False) instead, which is "
"available since Matplotlib 3.10.",
)
Comment on lines +716 to +720

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The first arg is since, not the full message.

Suggested change
_api.warn_deprecated(
"rcParams._get('backend') is deprecated since Matplotlib 3.11. "
"Use matplotlib.get_backend(auto_select=False) instead, which is "
"available since Matplotlib 3.10.",
)
_api.warn_deprecated(
"3.11",
name="rcParams._get('backend')",
addendum="Use matplotlib.get_backend(auto_select=False) instead, which is "
"available since Matplotlib 3.10.",
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please bump to 3.12 as well.

# TODO: When removing this, also remove the suppression context in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What is "this"? The comment is in an odd spot to decide if it's the if, the warning, or the whole method.

# RcParams.copy
return dict.__getitem__(self, key)

def _update_raw(self, other_params):
Expand Down Expand Up @@ -813,8 +821,11 @@ def find_all(self, pattern):
def copy(self):
"""Copy this RcParams instance."""
rccopy = self.__class__()
for k in self: # Skip deprecations and revalidation.
rccopy._set(k, self._get(k))
with _api.suppress_matplotlib_deprecation_warning():
# the suppression context is specifically for _get("backend"). This
# can be removed again, when "backend" is not a valid rcParam anymore.
for k in self: # Skip deprecations and revalidation.
rccopy._set(k, self._get(k))
return rccopy


Expand Down Expand Up @@ -1278,23 +1289,14 @@ def get_backend(*, auto_select=True):

.. versionadded:: 3.10

.. admonition:: Provisional

The *auto_select* flag is provisional. It may be changed or removed
without prior warning.

See Also
--------
matplotlib.use
"""
if auto_select:
return rcParams['backend']
else:
backend = rcParams._get('backend')
if backend is rcsetup._auto_backend_sentinel:
return None
else:
return backend
return rcParams._get_backend_or_none()


def interactive(b):
Expand Down
Loading

Back | FazBrowse Home | New Git URL