From: Ryan M. <rm...@gm...> - 2009-02-13 17:49:43
|
On Fri, Feb 13, 2009 at 3:24 AM, Richard Jennings <rpj...@gm...>wrote: > Hi, > > I am not expert in matplotlib, I use it to generate plots for a management > performance tool. > > I have just upgraded this application from 0.98.3 to 0.98.5 and the > upgrade broke the application in 3 places: > > > > 1). In units.py, Registry.get_converter(): this method has been made > recursive in 0.98.5. The problem is that if x is a string then you get a > recursion error. > > The cause is the 'iterable() function called in the line "if converter is > None and interable(x):" The interable() function is in cbook.py and it > actually tests to see if the object 'x' has a __len__() method. Call > iterable() on a string and it returns true. > > Do " for thisx in x:" and you will always get the first character in the > string, which is.... a string! > > My solution was to change iterable(): > > Def iterable(obj): > > """ > > Return true if **obj** is iterable > > """ > > try: obj.__iter__() > > except AtributeError: return False > > return True > > > > this seems to have solved the problem. > This has been fixed on the SVN trunk. FYI, the problem with your fix above is that, in general, we want strings to be considered iterable -- just not in this case. It should also be noted that the purpose of the fix was to eliminate the confusing infinite recursion. The fact that plotting strings of numbers works is a coincidence of how matplotlib is coded up and really should not be considered a supported feature. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma Sent from: Norman Oklahoma United States. |