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 b4ee5db

Browse filesBrowse files
committed
Set __name__ for list validators in rcsetup.
This avoids having many validators all named `f`, which makes profiling a bit difficult (it appears that repeated validation of rcparams when resetting the style at the beginning of each test instance contributes quite a bit to the total test time). Instead, the list validator based on scalar validator function `validate_foo` is now `__name__`d `validate_foolist`, and the list validator based on scalar validator class `ValidateFoo` is now `__name__`d `ValidateFooList`.
1 parent 8a77cfb commit b4ee5db
Copy full SHA for b4ee5db

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ def f(s):
9595
return [scalar_validator(v) for v in s
9696
if not isinstance(v, six.string_types) or v]
9797
else:
98-
msg = "{0!r} must be of type: string or non-dictionary iterable.".format(s)
99-
raise ValueError(msg)
98+
raise ValueError("{!r} must be of type: string or non-dictionary "
99+
"iterable".format(s))
100+
# Cast `str` to keep Py2 happy despite `unicode_literals`.
101+
try:
102+
f.__name__ = str("{}list".format(scalar_validator.__name__))
103+
except AttributeError: # class instance.
104+
f.__name__ = str("{}List".format(type(scalar_validator).__name__))
100105
f.__doc__ = scalar_validator.__doc__
101106
return f
102107

0 commit comments

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