[Fwd: IPython Crash Report]

Hi all,

as always, in threaded mode ipython creates crash reports for exceptions in threads. I think the one below belongs in the matplotlib court.

Cheers,

f

ps - for ipython 0.7.0 I changed things, so now exceptions in threads will get nicely formatted on-screen (including pdb support) instead of dumping these bogus crash reports.

···

-------- Original Message --------
Subject: IPython Crash Report
Date: Tue, 3 Jan 2006 16:55:10 -0500
From: Yoshua Bengio <bengioy@...301...>
To: fperez@...76...

***************************************************************************

IPython post-mortem report

IPython version: 0.6.15

Platform info : os.name -> posix, sys.platform -> linux2

***************************************************************************

Current user configuration structure:

{'Version': 0,
  'alias': [],
  'args': [],
  'autocall': 1,
  'autoindent': 1,
  'automagic': 1,
  'banner': 1,
  'c': '',
  'cache_size': 1000,
  'classic': 0,
  'color_info': 1,
  'colors': 'Linux',
  'confirm_exit': 1,
  'debug': 0,
  'deep_reload': 0,
  'editor': 'emacs -nw',
  'execfile': [],
  'execute': [''],
  'gthread': 0,
  'help': 0,
  'ignore': 0,
  'import_all': [],
  'import_mod': [],
  'import_some': [[]],
  'include': [],
  'ipythondir': '/u/bengioy/.ipython',
  'log': 0,
  'logfile': '',
  'logplay': '',
  'magic_docstrings': 0,
  'messages': 1,
  'multi_line_specials': 1,
  'nosep': 0,
  'opts': Struct({'pylab': 1}),
  'pdb': 0,
  'pprint': 1,
  'profile': '',
  'prompt_in1': 'In [\\#]: ',
  'prompt_in2': ' .\\D.: ',
  'prompt_out': 'Out[\\#]: ',
  'prompts_pad_left': 1,
  'pylab': 1,
  'qthread': 0,
  'quick': 0,
  'rcfile': 'ipythonrc',
  'readline': 1,
  'readline_merge_completions': 1,
  'readline_omit__names': 0,
  'readline_parse_and_bind': ['tab: complete',
                              '"\\C-l": possible-completions',
                              'set show-all-if-ambiguous on',
                              '"\\C-o": tab-insert',
                              '"\\M-i": " "',
                              '"\\M-o": "\\d\\d\\d\\d"',
                              '"\\M-I": "\\d\\d\\d\\d"',
                              '"\\C-r": reverse-search-history',
                              '"\\C-s": forward-search-history',
                              '"\\C-p": history-search-backward',
                              '"\\C-n": history-search-forward',
                              '"\\e[A": history-search-backward',
                              '"\\e[B": history-search-forward'],
  'readline_remove_delims': '-/~',
  'screen_length': -2,
  'separate_in': '\n',
  'separate_out': '',
  'separate_out2': '',
  'system_verbose': 0,
  'tk': 0,
  'upgrade': 0,
  'wthread': 0,
  'xmode': 'Context'}

***************************************************************************

Crash traceback:

---------------------------------------------------------------------------
exceptions.TypeError Python 2.4.1: /usr/bin/python
                                                    Tue Jan 3 16:55:02 2006
A problem occured executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/backends/backend_gtk.py in expose_event(self=<FigureCanvasGTKAgg object (GtkDrawingArea)>, widget=<FigureCanvasGTKAgg object (GtkDrawingArea)>, event=<GdkEvent>)
     262 self._renderer._set_width_height (width, height)
     263 self.figure.draw (self._renderer)
     264
     265
     266 def expose_event(self, widget, event):
     267 """Expose_event for all GTK backends
     268 Should not be overridden.
     269 """
     270 if DEBUG: print 'FigureCanvasGTK.%s' % fn_name()
     271
     272 if not GTK_WIDGET_DRAWABLE(self):
     273 return False
     274
     275 if self._draw_pixmap:
     276 width, height = self.allocation.width, self.allocation.height
--> 277 self._render_figure(width, height)
         self._render_figure = <bound method FigureCanvasGTKAgg._render_figure of <FigureCanvasGTKAgg object (GtkDrawingArea) at 0x2aaab2488f00>>
         width = 640
         height = 480
     278 self.window.set_back_pixmap (self._pixmap, False)
     279 self.window.clear() # draw pixmap as the gdk.Window's bg
     280 self._draw_pixmap = False
     281 else: # workaround pygtk 2.6 problem - bg not being redrawn
     282 self.window.clear_area (event.area.x, event.area.y,
     283 event.area.width, event.area.height)
     284
     285 return False # allow signal to propagate further
     286
     287
     288 def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
     289 orientation='portrait'):
     290 # TODO - use gdk print figure?
     291 root, ext = os.path.splitext(filename)
     292 ext = ext[1:]

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/backends/backend_gtkagg.py in _render_figure(self=<FigureCanvasGTKAgg object (GtkDrawingArea)>, width=640, height=480)
      76 create_pixmap = False
      77 if width > self._pixmap_width:
      78 # increase the pixmap in 10%+ (rather than 1 pixel) steps
      79 self._pixmap_width = max (int (self._pixmap_width * 1.1), width)
      80 create_pixmap = True
      81
      82 if height > self._pixmap_height:
      83 self._pixmap_height = max (int (self._pixmap_height * 1.1), height)
      84 create_pixmap = True
      85
      86 if create_pixmap:
      87 if DEBUG: print 'FigureCanvasGTK._render_figure new pixmap'
      88 self._pixmap = gtk.gdk.Pixmap (self.window, self._pixmap_width,
      89 self._pixmap_height)
      90
---> 91 FigureCanvasAgg.draw(self)
         global FigureCanvasAgg.draw = <unbound method FigureCanvasAgg.draw>
         self = <FigureCanvasGTKAgg object (GtkDrawingArea) at 0x2aaab2488f00>
      92 agg_to_gtk_drawable(self._pixmap, self.renderer._renderer)
      93
      94 def blit(self):
      95 agg_to_gtk_drawable(self._pixmap, self.renderer._renderer)
      96 self.window.set_back_pixmap (self._pixmap, False)
      97 self.window.clear() # draw pixmap as the gdk.Window's bg
      98 self._draw_pixmap = False
      99
     100 def print_figure(self, filename, dpi=150,
     101 facecolor='w', edgecolor='w',
     102 orientation='portrait'):
     103 if DEBUG: print 'FigureCanvasGTKAgg.print_figure'
     104 # delete the renderer to prevent improper blitting after print
     105
     106 root, ext = os.path.splitext(filename)

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/backends/backend_agg.py in draw(self=<FigureCanvasGTKAgg object (GtkDrawingArea)>)
     354 The canvas the figure renders into. Calls the draw and print fig
     355 methods, creates the renderers, etc...
     356
     357 Public attribute
     358
     359 figure - A Figure instance
     360 """
     361
     362 def draw(self):
     363 """
     364 Draw the figure using the renderer
     365 """
     366 if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
     367
     368 renderer = self.get_renderer()
--> 369 self.figure.draw(renderer)
         self.figure.draw = <bound method Figure.draw of <matplotlib.figure.Figure instance at 0x2aaab248d8c0>>
         renderer = <matplotlib.backends.backend_agg.RendererAgg instance at 0x2aaab2661e18>
     370
     371 def get_renderer(self):
     372 l,b,w,h = self.figure.bbox.get_bounds()
     373 key = w, h, self.figure.dpi.get()
     374 try: self._lastKey, self.renderer
     375 except AttributeError: need_new_renderer = True
     376 else: need_new_renderer = (self._lastKey != key)
     377
     378 if need_new_renderer:
     379 self.renderer = RendererAgg(w, h, self.figure.dpi)
     380 self._lastKey = key
     381 return self.renderer
     382
     383 def tostring_rgb(self):
     384 if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb', 'debug-annoying')

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/figure.py in draw(self=<matplotlib.figure.Figure instance>, renderer=<matplotlib.backends.backend_agg.RendererAgg instance>)
     483 # list of (_image.Image, ox, oy)
     484 if not allequal([im.origin for im in self.images]):
     485 raise ValueError('Composite images with different origins not supported')
     486 else:
     487 origin = self.images[0].origin
     488
     489 ims = [(im.make_image(), im.ox, im.oy) for im in self.images]
     490 im = _image.from_images(self.bbox.height(), self.bbox.width(), ims)
     491 im.is_grayscale = False
     492 l, b, w, h = self.bbox.get_bounds()
     493 renderer.draw_image(0, 0, im, origin, self.bbox)
     494
     495
     496
     497 # render the axes
--> 498 for a in self.axes: a.draw(renderer)
         a = <matplotlib.axes.Subplot instance at 0x2aaab248dab8>
         self.axes = [<matplotlib.axes.Subplot instance at 0x2aaab248dab8>]
         a.draw = <bound method Subplot.draw of <matplotlib.axes.Subplot instance at 0x2aaab248dab8>>
         renderer = <matplotlib.backends.backend_agg.RendererAgg instance at 0x2aaab2661e18>
     499
     500 # render the figure text
     501 for t in self.texts: t.draw(renderer)
     502
     503 for legend in self.legends:
     504 legend.draw(renderer)
     505
     506 self.transFigure.thaw() # release the lazy objects
     507 renderer.close_group('figure')
     508
     509 def get_axes(self):
     510 return self.axes
     511
     512 def legend(self, handles, labels, loc, **kwargs):
     513 """

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/axes.py in draw(self=<matplotlib.axes.Subplot instance>, renderer=<matplotlib.backends.backend_agg.RendererAgg instance>)
    1363
    1364
    1365
    1366 artists = []
    1367 artists.extend(self.collections)
    1368 artists.extend(self.patches)
    1369 artists.extend(self.lines)
    1370 artists.extend(self.texts)
    1371
    1372 # keep track of i to guarantee stable sort for python 2.2
    1373 dsu = [ (a.zorder, i, a) for i, a in enumerate(artists)
    1374 if a not in self.animated]
    1375 dsu.sort()
    1376
    1377 for zorder, i, a in dsu:
-> 1378 a.draw(renderer)
         a.draw = <bound method Text.draw of <matplotlib.text.Text instance at 0x2aaab2496200>>
         renderer = <matplotlib.backends.backend_agg.RendererAgg instance at 0x2aaab2661e18>
    1379
    1380 self.title.draw(renderer)
    1381 if 0: bbox_artist(self.title, renderer)
    1382 # optional artists
    1383 for a in self.artists:
    1384 a.draw(renderer)
    1385
    1386
    1387 if self.legend_ is not None:
    1388 self.legend_.draw(renderer)
    1389
    1390
    1391 for table in self.tables:
    1392 table.draw(renderer)
    1393

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/text.py in draw(self=<matplotlib.text.Text instance>, renderer=<matplotlib.backends.backend_agg.RendererAgg instance>)
     319 w, h = renderer.get_text_width_height(
     320 s, self._fontproperties, ismath)
     321
     322 renderx, rendery = thisx, thisy
     323 if renderer.flipy():
     324 canvasw, canvash = renderer.get_canvas_width_height()
     325 rendery = canvash-rendery
     326
     327 renderer.draw_text(gc, renderx, rendery, s,
     328 self._fontproperties, angle,
     329 ismath)
     330 thisx += w
     331
     332
     333 return
--> 334 bbox, info = self._get_layout(renderer)
         bbox = undefined
         info = undefined
         self._get_layout = <bound method Text._get_layout of <matplotlib.text.Text instance at 0x2aaab2496200>>
         renderer = <matplotlib.backends.backend_agg.RendererAgg instance at 0x2aaab2661e18>
     335
     336 if ismath=='TeX':
     337 canvasw, canvash = renderer.get_canvas_width_height()
     338 for line, wh, x, y in info:
     339 x, y = self._transform.xy_tup((x, y))
     340 if renderer.flipy():
     341 y = canvash-y
     342 renderer.draw_tex(gc, x, y, line,
     343 self._fontproperties, angle)
     344 return
     345
     346 for line, wh, x, y in info:
     347 x, y = self._transform.xy_tup((x, y))
     348 #renderer.draw_arc(gc, (1,0,0),
     349 # x, y, 2, 2, 0.0, 360.0)

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/text.py in _get_layout(self=<matplotlib.text.Text instance>, renderer=<matplotlib.backends.backend_agg.RendererAgg instance>)
     147 'Copy properties from t to self'
     148 Artist.update_from(self, other)
     149 self._color = other._color
     150 self._multialignment = other._multialignment
     151 self._verticalalignment = other._verticalalignment
     152 self._horizontalalignment = other._horizontalalignment
     153 self._fontproperties = other._fontproperties.copy()
     154 self._rotation = other._rotation
     155
     156
     157 def _get_layout(self, renderer):
     158
     159 # layout the xylocs in display coords as if angle = zero and
     160 # then rotate them around self._x, self._y
     161
--> 162 key = self.get_prop_tup()
         key = undefined
         self.get_prop_tup = <bound method Text.get_prop_tup of <matplotlib.text.Text instance at 0x2aaab2496200>>
     163 if self.cached.has_key(key): return self.cached[key]
     164
     165 horizLayout = []
     166 pad =2
     167 thisx, thisy = self._transform.xy_tup( (self._x, self._y) )
     168 width = 0
     169 height = 0
     170
     171 xmin, ymin = thisx, thisy
     172 if self.is_math_text():
     173 lines = [self._text]
     174 else:
     175 lines = self._text.split('\n')
     176
     177 whs = []

/u/lisa/local/linux-x86_64/lib/python2.3/site-packages/matplotlib/text.py in get_prop_tup(self=<matplotlib.text.Text instance>)
     406 return self._horizontalalignment
     407
     408 def get_position(self):
     409 "Return x, y as tuple"
     410 return self._x, self._y
     411
     412 def get_prop_tup(self):
     413 """
     414 Return a hashable tuple of properties
     415
     416 Not intended to be human readable, but useful for backends who
     417 want to cache derived information about text (eg layouts) and
     418 need to know if the text has changed
     419 """
     420
--> 421 x, y = self._transform.xy_tup((self._x, self._y))
         x = undefined
         y = undefined
         self._transform.xy_tup = <built-in method xy_tup of tuple object at 0x2aaab24c0a28>
         self._x = 1
         self._y = [2, 3]
     422 return (x, y, self._text, self._color,
     423 self._verticalalignment, self._horizontalalignment,
     424 hash(self._fontproperties), self._rotation)
     425
     426 def get_text(self):
     427 "Get the text as string"
     428 return self._text
     429
     430 def get_va(self):
     431 'alias for getverticalalignment'
     432 return self.get_verticalalignment()
     433
     434 def get_verticalalignment(self):
     435 "Return the vertical alignment as string"
     436 return self._verticalalignment

TypeError: float() argument must be a string or a number

***************************************************************************

History of session input:
from plot_representation import *
embeddings = [[1,2],[2,3],[1,4]]
names = ['ab','cde','fgh']
classes = [0,1,2]
plot_representation(embeddings,names,classes)

*** Last line of input (may not be in above history):