issues with plotting (maybe due to matplotlib)

Asked by Giulia Macaro on 2010-12-17

Hi,

I'm using yade-bzr2612 on ubuntu 9.10. The plot window crashes at some point almost in every simulation, regardless the simulation it's running.

When it happens in the terminal I got:

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (550, 0))

---------------------------------------------------------------------------
KeyError Traceback (most recent call last)

/usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.pyc in mouseReleaseEvent(self, event)
    134 y = self.figure.bbox.height - event.y()
    135 button = self.buttond[event.button()]
--> 136 FigureCanvasBase.button_release_event( self, x, y, button )
    137 if DEBUG: print 'button released'
    138

/usr/lib/pymodules/python2.6/matplotlib/backend_bases.pyc in button_release_event(self, x, y, button, guiEvent)
   1217 s = 'button_release_event'
   1218 event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)
-> 1219 self.callbacks.process(s, event)
   1220 self._button = None
   1221

...and continues with something similar for other a while (do you need the whole output?)... and then:

KeyError: (0.0, 0.00019999999999999987, u'0.0002', 'k', 'center', 'right', 7623432979757281113, None, 80, 79854408)

At this point I close the window plot (with the simulation still running), and open it again with the F8 command. Sometimes it works, sometimes I got:

RuntimeError Traceback (most recent call last)

/home/giulia/YADE/lib/yade-bzr2612/py/yade/__init__.pyc in <module>()
----> 1
      2
      3
      4
      5

/home/giulia/YADE/lib/yade-bzr2612/py/yade/plot.pyc in plot(noShow, subPlots)
    254 .. note:: For backwards compatibility reasons, *noShow* option will return list of figures for multiple figures but a single figure (rather than list with 1 element) if there is only 1 figure.
    255 """
--> 256 createPlots(subPlots=subPlots)
    257 global currLineRefs
    258 if not noShow:

/home/giulia/YADE/lib/yade-bzr2612/py/yade/plot.pyc in createPlots(subPlots)
    148 global currLineRefs
    149 figs=set([l.line.get_axes().get_figure() for l in currLineRefs]) # get all current figures
--> 150 for f in figs: pylab.close(f) # close those
    151 currLineRefs=[] # remove older plots (breaks live updates of windows that are still open)
    152 if len(plots)==0: return # nothing to plot

/usr/lib/pymodules/python2.6/matplotlib/pyplot.pyc in close(*args)
    334 if manager.canvas.figure==arg:
    335 manager.canvas.mpl_disconnect(manager._cidgcf)
--> 336 _pylab_helpers.Gcf.destroy(manager.num)
    337 else:
    338 raise TypeError('Unrecognized argument type %s to close'%type(arg))

/usr/lib/pymodules/python2.6/matplotlib/_pylab_helpers.pyc in destroy(num)
     61 del Gcf.figs[num]
     62 #print len(Gcf.figs.keys()), len(Gcf._activeQue)

---> 63 figManager.destroy()
     64 gc.collect()
     65

/usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.pyc in destroy(self, *args)
    278 self.window._destroying = True
    279 QtCore.QObject.disconnect( self.window, QtCore.SIGNAL( 'destroyed()' ),
--> 280 self._widgetclosed )
    281 if self.toolbar: self.toolbar.destroy()
    282 if DEBUG: print "destroy figure manager"

RuntimeError: underlying C/C++ object has been deleted

Could it be related to the python version (Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2) I'm using?
or do I need any other python package?

It's not that I can't run the simulation as it works now, but it's a bit annoying.

Thank you
Giulia

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2010-12-18
Last reply:
2010-12-18
Hadda (hadda) said : #1

Hi,

Try to print the data you want to plot on the terminal, you may have
some voids with 'none' values. Python can't handle it !

Nejib

Le vendredi 17 décembre 2010 à 12:48 +0000, Giulia Macaro a écrit :
> New question #138108 on Yade:
> https://answers.launchpad.net/yade/+question/138108
>
> Hi,
>
> I'm using yade-bzr2612 on ubuntu 9.10. The plot window crashes at some point almost in every simulation, regardless the simulation it's running.
>
> When it happens in the terminal I got:
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (550, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (550, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (550, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (550, 0))
>
> ---------------------------------------------------------------------------
> KeyError Traceback (most recent call last)
>
> /usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.pyc in mouseReleaseEvent(self, event)
> 134 y = self.figure.bbox.height - event.y()
> 135 button = self.buttond[event.button()]
> --> 136 FigureCanvasBase.button_release_event( self, x, y, button )
> 137 if DEBUG: print 'button released'
> 138
>
> /usr/lib/pymodules/python2.6/matplotlib/backend_bases.pyc in button_release_event(self, x, y, button, guiEvent)
> 1217 s = 'button_release_event'
> 1218 event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)
> -> 1219 self.callbacks.process(s, event)
> 1220 self._button = None
> 1221
>
>
>
>
> ...and continues with something similar for other a while (do you need the whole output?)... and then:
>
> KeyError: (0.0, 0.00019999999999999987, u'0.0002', 'k', 'center', 'right', 7623432979757281113, None, 80, 79854408)
>
>
> At this point I close the window plot (with the simulation still running), and open it again with the F8 command. Sometimes it works, sometimes I got:
>
>
>
> RuntimeError Traceback (most recent call last)
>
> /home/giulia/YADE/lib/yade-bzr2612/py/yade/__init__.pyc in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /home/giulia/YADE/lib/yade-bzr2612/py/yade/plot.pyc in plot(noShow, subPlots)
> 254 .. note:: For backwards compatibility reasons, *noShow* option will return list of figures for multiple figures but a single figure (rather than list with 1 element) if there is only 1 figure.
> 255 """
> --> 256 createPlots(subPlots=subPlots)
> 257 global currLineRefs
> 258 if not noShow:
>
> /home/giulia/YADE/lib/yade-bzr2612/py/yade/plot.pyc in createPlots(subPlots)
> 148 global currLineRefs
> 149 figs=set([l.line.get_axes().get_figure() for l in currLineRefs]) # get all current figures
> --> 150 for f in figs: pylab.close(f) # close those
> 151 currLineRefs=[] # remove older plots (breaks live updates of windows that are still open)
> 152 if len(plots)==0: return # nothing to plot
>
> /usr/lib/pymodules/python2.6/matplotlib/pyplot.pyc in close(*args)
> 334 if manager.canvas.figure==arg:
> 335 manager.canvas.mpl_disconnect(manager._cidgcf)
> --> 336 _pylab_helpers.Gcf.destroy(manager.num)
> 337 else:
> 338 raise TypeError('Unrecognized argument type %s to close'%type(arg))
>
> /usr/lib/pymodules/python2.6/matplotlib/_pylab_helpers.pyc in destroy(num)
> 61 del Gcf.figs[num]
> 62 #print len(Gcf.figs.keys()), len(Gcf._activeQue)
>
> ---> 63 figManager.destroy()
> 64 gc.collect()
> 65
>
> /usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.pyc in destroy(self, *args)
> 278 self.window._destroying = True
> 279 QtCore.QObject.disconnect( self.window, QtCore.SIGNAL( 'destroyed()' ),
> --> 280 self._widgetclosed )
> 281 if self.toolbar: self.toolbar.destroy()
> 282 if DEBUG: print "destroy figure manager"
>
> RuntimeError: underlying C/C++ object has been deleted
>
>
>
>
> Could it be related to the python version (Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
> [GCC 4.4.1] on linux2) I'm using?
> or do I need any other python package?
>
> It's not that I can't run the simulation as it works now, but it's a bit annoying.
>
> Thank you
> Giulia
>
>
>
>
>

Václav Šmilauer (eudoxos) said : #2

Hi Giulia,

a few questions"

1. From what you posted, it seems that the error is triggered by clicking on the plot window. Can you confirm/refute that?

2. Did plotting work flawlessly before and now it broke? The other option is that it was always like that or you did not try to plot. If it changed recently, it would be a good pointer, though I am not aware of any changes there recently.

3. Can you try setting plot.live=False before the actual plot is created? That would narrow the source to the event handling, which seems to get in loop somehow... Like this:

  from yade import plot
  plot.live=False # only add this line
  plot.plot(...)

4. Since you say it happens every time at your machine, could you reproduce the issue at another computer, with a newer version of Ubuntu (10.04 for instance)? If it works, then it would be an issue in pyqt/matplotlib; we could backporst newer version of matplotlib to 9.10 easily, but doing the same with pyqt4 would be more involved, if at all feasible.

Nejib, what do you mean that python cannot handle 'none' values? Do you mean NaN? Or None? NaN's are skipped in plots, while plotting None (if you manage to smuggle it in to plot.data, which would be surprising) will raise a clear "TypeError: a float is required" exception.

Giulia Macaro (giulia-macaro) said : #3

It happens with every script, no matter what data I have.

1. It happens sooner when I click on the plot window (and use the subplot configuration tool). But sometimes it happens even if I don't do anything.

2. It was always like that. I haven't said anything before cause I thought I could fix it by myself. I was wrong.

3. By setting plot.live=False, the plot doesn't change with time, but in this way it doesn't crash.
With the F8 command I still have the error sometimes as before, but when I manage to open the plot it doesn't crash.

4. What do you mean? It doesn't happen at Chiara's computer, but she has a newer version of Ubuntu.

Giulia Macaro (giulia-macaro) said : #4

Another person who's running yade on Ubuntu 9.10 has the same issue.
If fixing it is too complicated, don't do it, I can work with that. Don't worry.

Václav Šmilauer (eudoxos) said : #5

Hi there, I had the matplotlib package rebuild in 9.10 yesterday: https://launchpad.net/~yade-users/+archive/external?field.series_filter=karmic (it failed for i386 for dependency reasons, but I think you're running 64bit system anyway); you can install it by running

  sudo add-apt-repository ppa:yade-users/external && sudo apt-get update && sudo apt-get install python-matplotlib

[I would say you should consider updating your system to 10.04; that one has long-term support and, as always, newer versions of everything]

Giulia Macaro (giulia-macaro) said : #6

Hey,

I'm trying to install them, but I've got some errors:

Err http://ppa.launchpad.net karmic/main Packages
  404 Not Found

W: Failed to fetch http://ppa.launchpad.net/yade-users/externa/ubuntu/dists/karmic/main/binary-amd64/Packages.gz 404 Not Found

E: Some index files failed to download, they have been ignored, or old ones used instead.

and so in this way the plot windows still continues to crash at some point.

The problem with updating Ubuntu to 10.04 in a Dell T550 is that a lot of people had issues related to the screen (http://ubuntuforums.org/showthread.php?t=1555216). I'd update it, but then I'm not sure that I'll be able to fix it.

Václav Šmilauer (eudoxos) said : #7

Check the spelling, it should be yade-users/external (note the "l" at the end; you can copy & paste into terminal).

You might want to remove the wrong one (without "l") before doing it again, you can do it in System/Administration/Software Sources (or something like that).

For the update -- they suggest only to add the "nomodeset" parameter to the kernel (which can be even done at distance); of course it is your decision and I don't want to be blamed for eventual problems, even though I would not expect them ;-)

Can you help with this problem?

Provide an answer of your own, or ask Giulia Macaro for more information if necessary.

To post a message you must log in.