jeudi 10 avril 2014

matplotlib - AttributeError: « numpy.float64 » objet n'a aucun attribut « _mask » - Stack Overflow


I’m using matplotlib with the WX backend. I occasionally get an exception like this


Traceback (most recent call last):
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py", line 1029, in _onPaint
self.draw(drawDC=drawDC)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py", line 44, in draw
FigureCanvasAgg.draw(self)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 451, in draw
self.figure.draw(self.renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/figure.py", line 1034, in draw
func(*args)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/axes.py", line 2086, in draw
a.draw(renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/axis.py", line 1096, in draw
tick.draw(renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/axis.py", line 241, in draw
self.label1.draw(renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/text.py", line 598, in draw
ismath=ismath, mtext=self)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 188, in draw_text
font.get_image(), np.round(x - xd), np.round(y + yd) + 1, angle, gc)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 2629, in round_
return round(decimals, out)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/numpy/ma/core.py", line 4855, in round
result._mask = self._mask
AttributeError: 'numpy.float64' object has no attribute '_mask'

the first time I try to add data to a plot. My code looks like


self.line, = self.axes.plot(xvalues, yvalues)

where xvalues and yvalues are Python lists of Python numbers—I haven’t explicitly involved numpy at all. I have only seen this error once per application run, which means that my subsequent attempts to update the data with


self.line.set_data(xvalues, yvalues)

proceed without a problem. Any idea what’s going on here?



I’m using matplotlib with the WX backend. I occasionally get an exception like this


Traceback (most recent call last):
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py", line 1029, in _onPaint
self.draw(drawDC=drawDC)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py", line 44, in draw
FigureCanvasAgg.draw(self)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 451, in draw
self.figure.draw(self.renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/figure.py", line 1034, in draw
func(*args)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/axes.py", line 2086, in draw
a.draw(renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/axis.py", line 1096, in draw
tick.draw(renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/axis.py", line 241, in draw
self.label1.draw(renderer)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/text.py", line 598, in draw
ismath=ismath, mtext=self)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 188, in draw_text
font.get_image(), np.round(x - xd), np.round(y + yd) + 1, angle, gc)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 2629, in round_
return round(decimals, out)
File "/Users/bdesham/Code/virtualenv/lib/python2.7/site-packages/numpy/ma/core.py", line 4855, in round
result._mask = self._mask
AttributeError: 'numpy.float64' object has no attribute '_mask'

the first time I try to add data to a plot. My code looks like


self.line, = self.axes.plot(xvalues, yvalues)

where xvalues and yvalues are Python lists of Python numbers—I haven’t explicitly involved numpy at all. I have only seen this error once per application run, which means that my subsequent attempts to update the data with


self.line.set_data(xvalues, yvalues)

proceed without a problem. Any idea what’s going on here?


0 commentaires:

Enregistrer un commentaire