@@ -171,17 +171,20 @@ def __init__(self, data=None):
171171 self .update (data )
172172
173173 @staticmethod
174- def _str_is_convertable ( val ):
174+ def _strs_are_convertible ( vals ):
175175 """
176- Helper method to see if string can be cast to float or parsed as date.
176+ Helper method to see if list of strings can all be cast to float or
177+ parsed as date.
177178 """
178- try :
179- float (val )
180- except ValueError :
179+
180+ for val in vals :
181181 try :
182- dateutil . parser . parse (val )
182+ float (val )
183183 except ValueError :
184- return False
184+ try :
185+ dateutil .parser .parse (val )
186+ except ValueError :
187+ return False
185188 return True
186189
187190 def update (self , data ):
@@ -199,16 +202,14 @@ def update(self, data):
199202 """
200203 data = np .atleast_1d (np .array (data , dtype = object ))
201204
202- convertable = True
203205 for val in OrderedDict .fromkeys (data ):
204206 # OrderedDict just iterates over unique values in data.
205207 if not isinstance (val , (str , bytes )):
206208 raise TypeError ("{val!r} is not a string" .format (val = val ))
207- # check if we can convert string to number or date...
208- convertable = (convertable and self ._str_is_convertable (val ))
209209 if val not in self ._mapping :
210210 self ._mapping [val ] = next (self ._counter )
211- if convertable :
211+ # check if we can convert all strings to number or date...
212+ if self ._strs_are_convertible (data ):
212213 cbook ._warn_external ('using category units to plot a list of '
213214 'strings that is a;; floats or parsable as dates. '
214215 'If you do not mean these to be categories, cast '
0 commit comments