MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / f

Function f

lib/matplotlib/rcsetup.py:128–154  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

126def _listify_validator(scalar_validator, allow_stringlist=False, *,
127 n=None, doc=None):
128 def f(s):
129 if isinstance(s, str):
130 try:
131 val = [scalar_validator(v.strip()) for v in s.split(',')
132 if v.strip()]
133 except Exception:
134 if allow_stringlist:
135 # Special handling for colors
136 val = _single_string_color_list(s, scalar_validator)
137 else:
138 raise
139 # Allow any ordered sequence type -- generators, np.ndarray, pd.Series
140 # -- but not sets, whose iteration order is non-deterministic.
141 elif np.iterable(s) and not isinstance(s, (set, frozenset)):
142 # The condition on this list comprehension will preserve the
143 # behavior of filtering out any empty strings (behavior was
144 # from the original validate_stringlist()), while allowing
145 # any non-string/text scalar values such as numbers and arrays.
146 val = [scalar_validator(v) for v in s
147 if not isinstance(v, str) or v]
148 else:
149 raise ValueError(
150 f"Expected str or other non-set iterable, but got {s}")
151 if n is not None and len(val) != n:
152 raise ValueError(
153 f"Expected {n} values, but there are {len(val)} values in {s}")
154 return val
155
156 try:
157 f.__name__ = f"{scalar_validator.__name__}list"

Callers 4

inner_funcMethod · 0.70
wrapperFunction · 0.70
_integrate_rk12Function · 0.70
_euler_stepFunction · 0.70

Calls 1

Tested by

no test coverage detected