Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues with pyparsing 1.5.7 and python 2.7 #2338

Merged
merged 1 commit into from Aug 26, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Aug 26, 2013

You can reproduce this error with

In [13]: ax = gca()

In [14]: plot(range(1, 15))
Out[14]: [<matplotlib.lines.Line2D at 0x9735890>]

In [15]: ax.set_yscale('log')

In [16]: draw()

It works properly if you update to 2.0.1.

1.5.7 is the system version that is in the current ubuntu beta.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-46f60fa8c8fd> in <module>()
----> 1 exec(compile(open('/tmp/ipython-4094kLU.py').read(), '/tmp/ipython-4094kLU.py', 'exec')) # PYTHON-MODE

/tmp/ipython-4094kLU.py in <module>()

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/pyplot.pyc in draw()
    556 
    557     """
--> 558     get_current_fig_manager().canvas.draw()
    559 
    560 

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.pyc in draw(self)
    159         # causes problems with code that uses the result of the
    160         # draw() to update plot elements.
--> 161         FigureCanvasAgg.draw(self)
    162         self.update()
    163 

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_agg.pyc in draw(self)
    449 
    450         try:
--> 451             self.figure.draw(self.renderer)
    452         finally:
    453             RendererAgg.lock.release()

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     52     def draw_wrapper(artist, renderer, *args, **kwargs):
     53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
     55         after(artist, renderer)
     56 

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/figure.pyc in draw(self, renderer)
    964         if self.get_tight_layout() and self.axes:
    965             try:
--> 966                 self.tight_layout(renderer, **self._tight_parameters)
    967             except ValueError:
    968                 pass

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/figure.pyc in tight_layout(self, renderer, pad, h_pad, w_pad, rect)
   1603                                          renderer,
   1604                                          pad=pad, h_pad=h_pad, w_pad=w_pad,
-> 1605                                          rect=rect)
   1606 
   1607         self.subplots_adjust(**kwargs)

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/tight_layout.pyc in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
    350                                      subplot_list=subplot_list,
    351                                      ax_bbox_list=ax_bbox_list,
--> 352                                      pad=pad, h_pad=h_pad, w_pad=w_pad)
    353 
    354     if rect is not None:

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/tight_layout.pyc in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    127         #ax_bbox = union([ax.get_position(original=True) for ax in subplots])
    128 
--> 129         tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
    130         tight_bbox = TransformedBbox(tight_bbox_raw,
    131                                      fig.transFigure.inverted())

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/axes/_base.pyc in get_tightbbox(self, renderer, call_axes_locator)
   3184             bb.append(self._right_title.get_window_extent(renderer))
   3185 
-> 3186         bb_xaxis = self.xaxis.get_tightbbox(renderer)
   3187         if bb_xaxis:
   3188             bb.append(bb_xaxis)

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/axis.pyc in get_tightbbox(self, renderer)
   1058         ticks_to_draw = self._update_ticks(renderer)
   1059         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
-> 1060                                                                 renderer)
   1061 
   1062         self._update_label_position(ticklabelBoxes, ticklabelBoxes2)

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/axis.pyc in _get_tick_bboxes(self, ticks, renderer)
   1041         for tick in ticks:
   1042             if tick.label1On and tick.label1.get_visible():
-> 1043                 extent = tick.label1.get_window_extent(renderer)
   1044                 ticklabelBoxes.append(extent)
   1045             if tick.label2On and tick.label2.get_visible():

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
    751             raise RuntimeError('Cannot get window extent w/o renderer')
    752 
--> 753         bbox, info, descent = self._get_layout(self._renderer)
    754         x, y = self.get_position()
    755         x, y = self.get_transform().transform_point((x, y))

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/text.pyc in _get_layout(self, renderer)
    327                 w, h, d = get_text_width_height_descent(clean_line,
    328                                                         self._fontproperties,
--> 329                                                         ismath=ismath)
    330             else:
    331                 w, h, d = 0, 0, 0

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_agg.pyc in get_text_width_height_descent(self, s, prop, ismath)
    208         if ismath:
    209             ox, oy, width, height, descent, fonts, used_characters = \
--> 210                 self.mathtext_parser.parse(s, self.dpi, prop)
    211             return width, height, descent
    212 

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/mathtext.pyc in parse(self, s, dpi, prop)
   3007         # with each request.
   3008         if self._parser is None:
-> 3009             self.__class__._parser = Parser()
   3010 
   3011         box = self._parser.parse(s, font_output, fontsize, dpi)

/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/mathtext.pyc in __init__(self)
   2191         space         <<= oneOf(self._space_widths.keys())
   2192         customspace   <<= (Suppress(Literal(r'\hspace'))
-> 2193                           - ((lbrace + float_literal + rbrace)
   2194                             | Error(r"Expected \hspace{n}")))
   2195 

TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

In [8]: Traceback (most recent call last):
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4.py", line 416, in idle_draw
    self.draw()
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py", line 161, in draw
    FigureCanvasAgg.draw(self)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 451, in draw
    self.figure.draw(self.renderer)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/figure.py", line 966, in draw
    self.tight_layout(renderer, **self._tight_parameters)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/figure.py", line 1605, in tight_layout
    rect=rect)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/tight_layout.py", line 352, in get_tight_layout_figure
    pad=pad, h_pad=h_pad, w_pad=w_pad)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/tight_layout.py", line 129, in auto_adjust_subplotpars
    tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/axes/_base.py", line 3186, in get_tightbbox
    bb_xaxis = self.xaxis.get_tightbbox(renderer)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 1060, in get_tightbbox
    renderer)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 1043, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/text.py", line 753, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/text.py", line 329, in _get_layout
    ismath=ismath)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 210, in get_text_width_height_descent
    self.mathtext_parser.parse(s, self.dpi, prop)
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/mathtext.py", line 3009, in parse
    self.__class__._parser = Parser()
  File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/mathtext.py", line 2193, in __init__
    - ((lbrace + float_literal + rbrace)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

@tacaswell
Copy link
Member Author

This is with current master, sorry for neglecting to include this.

@mdboom
Copy link
Member

mdboom commented Aug 26, 2013

Thanks for reporting. FWIW, pyparsing 1.5.6 works. I've confirmed that 1.5.7 does not. I'll see if I can work up something that works across these.

@mdboom
Copy link
Member

mdboom commented Aug 26, 2013

Also confirmed on 1.3.x branch of matplotlib.

@mdboom
Copy link
Member

mdboom commented Aug 26, 2013

@tacaswell: Would you mind testing the attached?

@tacaswell
Copy link
Member Author

@mdboom That patch fixes the problem for me.

mdboom added a commit that referenced this pull request Aug 26, 2013
issues with pyparsing 1.5.7 and python 2.7
@mdboom mdboom merged commit 42078bf into matplotlib:v1.3.x Aug 26, 2013
@mdboom mdboom deleted the mathtext-pyparsing157-crash branch August 7, 2014 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants