Crash when trying to show a semilog or log-log plot

I am using matplotlib-0.98.5.2 and getting a strange crash when trying to show() a window with semilog or log-log axes. Here is a simple script that will cause the crash:

import pylab
from numpy import *
x = arange(1., 10., 0.1)
y = x**2
pylab.semilogx(x,y)
pylab.show()

At the end of this message is a sample of the output. I had to cut it down because it's apparently stuck in a loop in pyparsing.py and keeps outputting the same repetitive message. Did I find a bug here? Any suggestions would be appreciated.

   Craig

Sample output:

···

------------------------------------------------------
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py", line 352, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in _render_figure
    FigureCanvasAgg.draw(self)
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 279, in draw
    self.figure.draw(self.renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/figure.py", line 772, in draw
    for a in self.axes: a.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1601, in draw
    a.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/axis.py", line 710, in draw
    tick.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/axis.py", line 193, in draw
    self.label1.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/text.py", line 452, in draw
    bbox, info = self._get_layout(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/text.py", line 252, in _get_layout
    w, h, d = renderer.get_text_width_height_descent(
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 152, in get_text_width_height_descent
    ox, oy, width, height, descent, fonts, used_characters = \
  File "//usr/lib/python2.4/site-packages/matplotlib/mathtext.py", line 2808, in parse
    box = self._parser.parse(s, font_output, fontsize, dpi)
  File "//usr/lib/python2.4/site-packages/matplotlib/mathtext.py", line 2259, in parse
    self._expression.parseString(s)
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 1065, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2577, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2325, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2690, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2325, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache

------------- snip -------------

File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2309, in parseImpl
    loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2321, in parseImpl
    raise ParseSyntaxException(pe)
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 230, in __init__
    super(ParseSyntaxException, self).__init__(
TypeError: super() argument 1 must be type, not classobj

Strange. I am unable to reproduce this with 0.98.2 (0.98.3 or 0.98.5)...

It's happening inside of the math expression renderer, which is used to draw the exponents that happen with semilog and log-log axes. It doesn't, however, appear to be font-related, which is a frequent installation/system problem.

What is strange about this traceback is that it is using the system-wide installed version of pyparsing.py, and not the one that comes with matplotlib. matplotlib is very sensitive to small version changes in pyparsing, so we distribute our own copy and try to use it. If you temporarily move /usr/lib/python2.4/site-packages/pyparsing.py to another location, does that solve the problem? If so, I will look into how we're importing pyparsing.py to ensure we always use the local copy.

Mike

Craig Finch wrote:

···

I am using matplotlib-0.98.5.2 and getting a strange crash when trying to show() a window with semilog or log-log axes. Here is a simple script that will cause the crash:

import pylab
from numpy import *
x = arange(1., 10., 0.1)
y = x**2
pylab.semilogx(x,y)
pylab.show()

At the end of this message is a sample of the output. I had to cut it down because it's apparently stuck in a loop in pyparsing.py and keeps outputting the same repetitive message. Did I find a bug here? Any suggestions would be appreciated.

   Craig

Sample output:
------------------------------------------------------
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py", line 352, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in _render_figure
    FigureCanvasAgg.draw(self)
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 279, in draw
    self.figure.draw(self.renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/figure.py", line 772, in draw
    for a in self.axes: a.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1601, in draw
    a.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/axis.py", line 710, in draw
    tick.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/axis.py", line 193, in draw
    self.label1.draw(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/text.py", line 452, in draw
    bbox, info = self._get_layout(renderer)
  File "//usr/lib/python2.4/site-packages/matplotlib/text.py", line 252, in _get_layout
    w, h, d = renderer.get_text_width_height_descent(
  File "//usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 152, in get_text_width_height_descent
    ox, oy, width, height, descent, fonts, used_characters = \
  File "//usr/lib/python2.4/site-packages/matplotlib/mathtext.py", line 2808, in parse
    box = self._parser.parse(s, font_output, fontsize, dpi)
  File "//usr/lib/python2.4/site-packages/matplotlib/mathtext.py", line 2259, in parse
    self._expression.parseString(s)
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 1065, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2577, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2325, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2690, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2325, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache

------------- snip -------------

File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2309, in parseImpl
    loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 998, in _parseCache
    value = self._parseNoCache( instring, loc, doActions, callPreParse )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 941, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 2321, in parseImpl
    raise ParseSyntaxException(pe)
  File "/usr/lib/python2.4/site-packages/pyparsing.py", line 230, in __init__
    super(ParseSyntaxException, self).__init__(
TypeError: super() argument 1 must be type, not classobj

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA