File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,28 +109,30 @@ def __init__(self,
109109 self .update (kwargs )
110110 self ._paths = None
111111
112-
113- def _get_value (self , val ):
114- try : return (float (val ), )
112+ @staticmethod
113+ def _get_value (val ):
114+ try :
115+ return (float (val ), )
115116 except TypeError :
116117 if cbook .iterable (val ) and len (val ):
117- try : float (val [0 ])
118- except TypeError : pass # raise below
119- except ValueError : pass
120- else : return val
118+ try :
119+ float (val [0 ])
120+ except (TypeError , ValueError ):
121+ pass # raise below
122+ else :
123+ return val
121124
122125 raise TypeError ('val must be a float or nonzero sequence of floats' )
123126
124- def _get_bool (self , val ):
125- try : return (bool (val ), )
126- except TypeError :
127- if cbook .iterable (val ) and len (val ):
128- try : bool (val [0 ])
129- except TypeError : pass # raise below
130- else : return val
131-
132- raise TypeError ('val must be a bool or nonzero sequence of them' )
133-
127+ @staticmethod
128+ def _get_bool (val ):
129+ if not cbook .iterable (val ):
130+ val = (val ,)
131+ try :
132+ bool (val [0 ])
133+ except (TypeError , IndexError ):
134+ raise TypeError ('val must be a bool or nonzero sequence of them' )
135+ return val
134136
135137 def get_paths (self ):
136138 return self ._paths
You can’t perform that action at this time.
0 commit comments