Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ab1350

Browse files
committed
refactored negative_linestyle option validation
svn path=/trunk/matplotlib/; revision=3437
1 parent 1104bd8 commit 1ab1350

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

lib/matplotlib/rcdefaults.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,20 @@ def validate_ps_distiller(s):
207207

208208
validate_capstyle = ValidateInStrings('capstyle',['butt', 'round', 'projecting'], ignorecase=True)
209209

210-
def validate_linecol_linestyle(s):
210+
validate_negative_linestyle = ValidateInStrings('negative_linestyle',['solid', 'dashed'], ignorecase=True)
211+
212+
def validate_negative_linestyle_legacy(s):
211213
try:
212-
dashes = validate_nseq_float(2)(s)
213-
warnings.warn("Deprecated negative_linestyle specification; use 'solid' or 'dashed'")
214-
return (0, dashes) # (offset, (solid, blank))
215-
except ValueError:
216-
V = ValidateInStrings('linecol_linestyle',['solid', 'dashed'], ignorecase=True)
217-
return(V(s))
214+
res = validate_negative_linestyle(s)
215+
return res
216+
except:
217+
try:
218+
dashes = validate_nseq_float(2)(s)
219+
warnings.warn("Deprecated negative_linestyle specification; use 'solid' or 'dashed'")
220+
return (0, dashes) # (offset, (solid, blank))
221+
except:
222+
pass
223+
raise
218224

219225
class ValidateInterval:
220226
"""
@@ -320,7 +326,7 @@ def __call__(self, s):
320326
'image.lut' : [256, validate_int], # lookup table
321327
'image.origin' : ['upper', str], # lookup table
322328

323-
'contour.negative_linestyle' : ['dashed', validate_linecol_linestyle],
329+
'contour.negative_linestyle' : ['dashed', validate_negative_linestyle_legacy],
324330

325331
# axes props
326332
'axes.axisbelow' : [False, validate_bool],

0 commit comments

Comments
 (0)