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

Skip to content

Commit 8d33b9b

Browse files
committed
Changed: Cleaned up style to conform, simplified boolexpr, and added back validator with allow_none to default dashes
1 parent 6f240f7 commit 8d33b9b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ def validate_maskedarray(v):
295295

296296
class validate_nseq_float(object):
297297
def __init__(self, n=None, allow_none=False):
298-
self.n, self.allow_none = n, allow_none
298+
self.n = n
299+
self.allow_none = allow_none
299300

300301
def __call__(self, s):
301302
"""return a seq of n floats or raise"""
@@ -310,8 +311,7 @@ def __call__(self, s):
310311

311312
try:
312313
return [float(val)
313-
if self.allow_none and val is not None
314-
or not self.allow_none
314+
if not self.allow_none or val is not None
315315
else val
316316
for val in s]
317317
except ValueError:
@@ -933,6 +933,7 @@ def _validate_linestyle(ls):
933933
raise ValueError("linestyle must be a string or " +
934934
"an even-length sequence of floats.")
935935

936+
936937
# a map from key -> value, converter
937938
defaultParams = {
938939
'backend': ['Agg', validate_backend], # agg is certainly
@@ -966,10 +967,10 @@ def _validate_linestyle(ls):
966967
'lines.solid_joinstyle': ['round', validate_joinstyle],
967968
'lines.dash_capstyle': ['butt', validate_capstyle],
968969
'lines.solid_capstyle': ['projecting', validate_capstyle],
969-
'lines.dashed_pattern': [[3.7, 1.6], validate_nseq_float()],
970+
'lines.dashed_pattern': [[3.7, 1.6], validate_nseq_float(allow_none=True)],
970971
'lines.dashdot_pattern': [[6.4, 1.6, 1, 1.6],
971-
validate_nseq_float()],
972-
'lines.dotted_pattern': [[1, 1.65], validate_nseq_float()],
972+
validate_nseq_float(allow_none=True)],
973+
'lines.dotted_pattern': [[1, 1.65], validate_nseq_float(allow_none=True)],
973974
'lines.scale_dashes': [True, validate_bool],
974975

975976
# marker props

0 commit comments

Comments
 (0)