Skip to content

Commit cc2f863

Browse files
timhoffmjklymak
andauthored
Apply suggestions from code review
Co-authored-by: Jody Klymak <jklymak@gmail.com>
1 parent a9c37b1 commit cc2f863

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

doc/api/next_api_changes/deprecations/24730-TH.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@ Relying on ``rcParams`` being a ``dict`` subclass is deprecated.
55
Nothing will change for regular users because ``rcParams`` will continue to
66
be dict-like (technically fulfill the ``MutableMapping`` interface).
77

8-
However, there are some rare known cases that use
9-
``dict.__getitem__(rcParams, key)`` and
10-
``dict.__setitem__(rcParams, key, val)`` for direct data access that
11-
circumvents any validation logic. While this is technically public, it
12-
depends on the implementation detail that ``rcParams`` is currently a ``dict``
13-
subclass.
8+
The `.RcParams` class does validation checking on calls to `.RcParams.__get_item__` and
9+
`.RcParams.__set_item__`. However, there are rare cases where we want to circumvents the
10+
validation logic and directly access the underlying data values. Previously, this could be
11+
accomplished via a call to the parent methods ``dict.__getitem__(rcParams, key)`` and ``dict.__setitem__(rcParams, key, val)``.
1412

1513
Matplotlib 3.7 introduces ``rcParams._set(key, val)`` and
16-
``rcParams._get(key)`` as a replacements for these cases. They are
17-
intentionally marked private because there is very little need for external
18-
users to use them. However, if you have a compelling reason for direct data
14+
``rcParams._get(key)`` as a replacement to calling the parent methods. They are
15+
intentionally marked private because there is little need for external
16+
users to use them. However, if you have a compelling reason for direct `.RcParam` data
1917
access, please switch from the dict functions to the new ``_get()`` and
2018
``_set()``. Even though marked private, we guarantee API stability for these
21-
methods, i.e., they are subject to Matplotlib's API and deprecation policy.
19+
methods and they are subject to Matplotlib's API and deprecation policy.
2220

2321
Please notify the Matplotlib developers if you rely on ``rcParams`` being a
2422
dict subclass in any other way, for which there is no migration path yet.

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _get_backend_mod():
200200
This is currently private, but may be made public in the future.
201201
"""
202202
if _backend_mod is None:
203-
# Use rcParams.get("backend") to avoid going through the fallback
203+
# Use rcParams._get("backend") to avoid going through the fallback
204204
# logic (which will (re)import pyplot and then call switch_backend if
205205
# we need to resolve the auto sentinel)
206206
switch_backend(rcParams._get("backend"))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy