Skip to content

Commit dee8e4f

Browse 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 dee8e4f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ 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+
try:
101+
f.__name__ = "{}list".format(scalar_validator.__name__)
102+
except AttributeError:
103+
f.__name__ = "{}List".format(type(scalar_validator).__name__)
100104
f.__doc__ = scalar_validator.__doc__
101105
return f
102106

0 commit comments

Comments
 (0)