Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a643878

Browse filesBrowse files
efiringMeeseeksDev[bot]
authored andcommitted
Backport PR #10531: Update matplotlibrc.template
1 parent e6172b5 commit a643878
Copy full SHA for a643878

File tree

Expand file treeCollapse file tree

2 files changed

+601
-522
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+601
-522
lines changed

‎lib/matplotlib/tests/test_rcparams.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_rcparams.py
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,64 @@ def test_rcparams_reset_after_fail():
422422
pass
423423

424424
assert mpl.rcParams['text.usetex'] is False
425+
426+
427+
def test_if_rctemplate_is_up_to_date():
428+
# This tests if the matplotlibrc.template file
429+
# contains all valid rcParams.
430+
dep1 = mpl._all_deprecated
431+
dep2 = mpl._deprecated_set
432+
deprecated = list(dep1.union(dep2))
433+
#print(deprecated)
434+
path_to_rc = mpl.matplotlib_fname()
435+
with open(path_to_rc, "r") as f:
436+
rclines = f.readlines()
437+
missing = {}
438+
for k,v in mpl.defaultParams.items():
439+
if k[0] == "_":
440+
continue
441+
if k in deprecated:
442+
continue
443+
if "verbose" in k:
444+
continue
445+
found = False
446+
for line in rclines:
447+
if k in line:
448+
found = True
449+
if not found:
450+
missing.update({k:v})
451+
if missing:
452+
raise ValueError("The following params are missing " +
453+
"in the matplotlibrc.template file: {}"
454+
.format(missing.items()))
455+
456+
457+
def test_if_rctemplate_would_be_valid(tmpdir):
458+
# This tests if the matplotlibrc.template file would result in a valid
459+
# rc file if all lines are uncommented.
460+
path_to_rc = mpl.matplotlib_fname()
461+
with open(path_to_rc, "r") as f:
462+
rclines = f.readlines()
463+
newlines = []
464+
for line in rclines:
465+
if line[0] == "#":
466+
newline = line[1:]
467+
else:
468+
newline = line
469+
if "$TEMPLATE_BACKEND" in newline:
470+
newline = "backend : Agg"
471+
if "datapath" in newline:
472+
newline = ""
473+
newlines.append(newline)
474+
d = tmpdir.mkdir('test1')
475+
fname = str(d.join('testrcvalid.temp'))
476+
with open(fname, "w") as f:
477+
f.writelines(newlines)
478+
with pytest.warns(None) as record:
479+
dic = mpl.rc_params_from_file(fname,
480+
fail_on_error=True,
481+
use_default_template=False)
482+
assert len(record) == 0
483+
#d1 = set(dic.keys())
484+
#d2 = set(matplotlib.defaultParams.keys())
485+
#print(d2-d1)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.