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

MNT: let bad rcParam keys pass by jklymak · Pull Request #19588 · 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  (2) All 1 file type 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
18 changes: 12 additions & 6 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 @@ -830,12 +830,18 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
rcParamsOrig = RcParams(rcParams.copy())
# This also checks that all rcParams are indeed listed in the template.
# Assigning to rcsetup.defaultParams is left only for backcompat.
defaultParams = rcsetup.defaultParams = {
# We want to resolve deprecated rcParams, but not backend...
key: [(rcsetup._auto_backend_sentinel if key == "backend" else
rcParamsDefault[key]),
validator]
for key, validator in rcsetup._validators.items()}
defaultParams = {}
for key, validator in rcsetup._validators.items():
if key == 'backend':
defaultParams['backend'] = [rcsetup._auto_backend_sentinel,
validator]
elif key in rcParamsDefault.keys():
defaultParams[key] = [rcParamsDefault[key], validator]
else:
_api.warn_external(f'rcsetup key "{key}" not in the default'
' rcParams')
rcsetup.defaultParams = defaultParams

if rcParams['axes.formatter.use_locale']:
locale.setlocale(locale.LC_ALL, '')

Expand Down
18 changes: 18 additions & 0 deletions lib/matplotlib/tests/test_rcparams.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 @@ -13,6 +13,7 @@
from matplotlib import _api, _c_internal_utils
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import matplotlib.rcsetup as rcsetup
import numpy as np
from matplotlib.rcsetup import (
validate_bool,
Expand All @@ -31,6 +32,23 @@
_listify_validator)


def test_rc_validators_in_sync():
# make sure that matplotlibrc.template and rcsetup._validators
# are in sync.
rc = mpl._rc_params_in_file(
'matplotlibrc.template',
# Strip leading comment.
transform=lambda line: line[1:] if line.startswith("#") else line,
fail_on_error=True)
for key, validator in rcsetup._validators.items():
if (key not in mpl._deprecated_remain_as_none and
key not in mpl._deprecated_ignore_map and
key[0] != '_'):
assert key in list(rc.keys())
for key in list(rc.keys()):
assert key in list(rcsetup._validators.keys())


def test_rcparams(tmpdir):
mpl.rc('text', usetex=False)
mpl.rc('lines', linewidth=22)
Expand Down

Back | FazBrowse Home | New Git URL