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 09141e9

Browse filesBrowse files
committed
fix error and from file
1 parent 6342bed commit 09141e9
Copy full SHA for 09141e9

File tree

1 file changed

+15
-18
lines changed
Filter options

1 file changed

+15
-18
lines changed

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+15-18Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""
1515

1616
import ast
17+
from collections.abc import Iterable
1718
from functools import lru_cache, reduce
1819
from numbers import Real
1920
import operator
@@ -97,10 +98,6 @@ def f(s):
9798
val = [scalar_validator(v.strip()) for v in s if v.strip()]
9899
else:
99100
raise
100-
elif isinstance(s, dict):
101-
# assume dict is a value in the iterator and not the iterator
102-
# since iterating over dict only iterates over keys
103-
val = [scalar_validator(s)]
104101
# Allow any ordered sequence type -- generators, np.ndarray, pd.Series
105102
# -- but not sets, whose iteration order is non-deterministic.
106103
elif np.iterable(s) and not isinstance(s, (set, frozenset)):
@@ -129,7 +126,6 @@ def f(s):
129126

130127
def validate_any(s):
131128
return s
132-
133129
validate_anylist = _listify_validator(validate_any)
134130

135131

@@ -574,11 +570,13 @@ def validate_path_effects(s):
574570
if not s:
575571
return []
576572

577-
if isinstance(s, str) and s.startswith("("):
573+
if isinstance(s, str) and s.strip().startswith("("):
578574
s = ast.literal_eval(s)
579-
580-
if not isinstance(s, list): #string tuple list mostly
581-
s = [s]
575+
s = [s] if isinstance(s[0], str) else s # cast to list for the 1 tuple case
576+
elif isinstance(s, Iterable):
577+
pass #validate list elements in the for loop to allow for mixed list
578+
else:
579+
ValueError("Expected a list of patheffects functions or (funcname, {**kwargs}) tuples")
582580

583581
_validate_name = ValidateInStrings("path.effects",
584582
["Normal",
@@ -590,20 +588,19 @@ def validate_path_effects(s):
590588
"withSimplePatchShadow",
591589
"withStroke",
592590
"withTickedStroke"])
591+
592+
593593
path_effects = []
594594

595595
for pe in s:
596596
#patheffects objects
597-
if getattr(pe, '__module__', "") == 'matplotlib.patheffects':
597+
if isinstance(pe, tuple):
598+
path_effects.append((_validate_name(pe[0]),
599+
{} if len(pe)<2 else pe[1]))
600+
elif getattr(pe, '__module__', "") == 'matplotlib.patheffects':
598601
path_effects.append(pe)
599-
continue
600-
601-
if not isinstance(pe, (tuple)):
602-
raise ValueError("Expected a list of tuples of the form: ('function name', {**kwargs})")
603-
604-
if len(pe) == 1:
605-
pe == (pe[0], {})
606-
path_effects.append((_validate_name(pe[0]), pe[1]))
602+
else:
603+
raise ValueError(f'Invalid entry for path.effects: {pe}')
607604

608605

609606
return path_effects

0 commit comments

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