@@ -294,8 +294,8 @@ def validate_maskedarray(v):
294
294
295
295
296
296
class validate_nseq_float (object ):
297
- def __init__ (self , n = None ):
298
- self .n = n
297
+ def __init__ (self , n = None , allow_none = False ):
298
+ self .n , self . allow_none = n , allow_none
299
299
300
300
def __call__ (self , s ):
301
301
"""return a seq of n floats or raise"""
@@ -309,7 +309,10 @@ def __call__(self, s):
309
309
raise ValueError (err_msg .format (n = self .n , num = len (s ), s = s ))
310
310
311
311
try :
312
- return [float (val ) for val in s ]
312
+ return [float (val )
313
+ if not self .allow_none and val is not None
314
+ else val
315
+ for val in s ]
313
316
except ValueError :
314
317
raise ValueError ('Could not convert all entries to floats' )
315
318
@@ -697,7 +700,7 @@ def validate_hatch(s):
697
700
raise ValueError ("Unknown hatch symbol(s): %s" % list (unknown ))
698
701
return s
699
702
validate_hatchlist = _listify_validator (validate_hatch )
700
- validate_dashlist = _listify_validator (validate_nseq_float ())
703
+ validate_dashlist = _listify_validator (validate_nseq_float (allow_none = True ))
701
704
702
705
_prop_validators = {
703
706
'color' : _listify_validator (validate_color_for_prop_cycle ,
@@ -929,7 +932,6 @@ def _validate_linestyle(ls):
929
932
raise ValueError ("linestyle must be a string or " +
930
933
"an even-length sequence of floats." )
931
934
932
-
933
935
# a map from key -> value, converter
934
936
defaultParams = {
935
937
'backend' : ['Agg' , validate_backend ], # agg is certainly
@@ -963,9 +965,10 @@ def _validate_linestyle(ls):
963
965
'lines.solid_joinstyle' : ['round' , validate_joinstyle ],
964
966
'lines.dash_capstyle' : ['butt' , validate_capstyle ],
965
967
'lines.solid_capstyle' : ['projecting' , validate_capstyle ],
966
- 'lines.dashed_pattern' : [[3.7 , 1.6 ], validate_nseq_float ()],
967
- 'lines.dashdot_pattern' : [[6.4 , 1.6 , 1 , 1.6 ], validate_nseq_float ()],
968
- 'lines.dotted_pattern' : [[1 , 1.65 ], validate_nseq_float ()],
968
+ 'lines.dashed_pattern' : [[3.7 , 1.6 ], validate_nseq_float (allow_none = True )],
969
+ 'lines.dashdot_pattern' : [[6.4 , 1.6 , 1 , 1.6 ],
970
+ validate_nseq_float (allow_none = True )],
971
+ 'lines.dotted_pattern' : [[1 , 1.65 ], validate_nseq_float (allow_none = True )],
969
972
'lines.scale_dashes' : [True , validate_bool ],
970
973
971
974
# marker props
0 commit comments