Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit09141e9

Browse files
committed
fix error and from file
1 parent6342bed commit09141e9

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

‎lib/matplotlib/rcsetup.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""
1515

1616
importast
17+
fromcollections.abcimportIterable
1718
fromfunctoolsimportlru_cache,reduce
1819
fromnumbersimportReal
1920
importoperator
@@ -97,10 +98,6 @@ def f(s):
9798
val= [scalar_validator(v.strip())forvinsifv.strip()]
9899
else:
99100
raise
100-
elifisinstance(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
elifnp.iterable(s)andnotisinstance(s, (set,frozenset)):
@@ -129,7 +126,6 @@ def f(s):
129126

130127
defvalidate_any(s):
131128
returns
132-
133129
validate_anylist=_listify_validator(validate_any)
134130

135131

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

577-
ifisinstance(s,str)ands.startswith("("):
573+
ifisinstance(s,str)ands.strip().startswith("("):
578574
s=ast.literal_eval(s)
579-
580-
ifnotisinstance(s,list):#string tuple list mostly
581-
s= [s]
575+
s= [s]ifisinstance(s[0],str)elses# cast to list for the 1 tuple case
576+
elifisinstance(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
forpeins:
596596
#patheffects objects
597-
ifgetattr(pe,'__module__',"")=='matplotlib.patheffects':
597+
ifisinstance(pe,tuple):
598+
path_effects.append((_validate_name(pe[0]),
599+
{}iflen(pe)<2elsepe[1]))
600+
elifgetattr(pe,'__module__',"")=='matplotlib.patheffects':
598601
path_effects.append(pe)
599-
continue
600-
601-
ifnotisinstance(pe, (tuple)):
602-
raiseValueError("Expected a list of tuples of the form: ('function name', {**kwargs})")
603-
604-
iflen(pe)==1:
605-
pe== (pe[0], {})
606-
path_effects.append((_validate_name(pe[0]),pe[1]))
602+
else:
603+
raiseValueError(f'Invalid entry for path.effects:{pe}')
607604

608605

609606
returnpath_effects

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp