[SciPy-dev] pickling problem

Darren Dale dd55 at cornell.edu
Wed Nov 30 14:04:27 CST 2005


I'm having some trouble with unpickled scipy arrays. The issue shows up when I 
try to plot in matplotlib, but I think it is a scipy problem.

import pickle
import scipy
import pylab

a = scipy.arange(10)
pickle.dump(a,file('temp.p','w'))
b = pickle.load(file('temp.p'))
print type(b), type(scipy.array(b))
pylab.plot(scipy.array(b)) # no error here
pylab.plot(b) # error here

Traceback (most recent call last):
  File "pickletest.py", line 8, in ?
    pylab.plot(b)
  File "/usr/lib64/python2.4/site-packages/matplotlib/pylab.py", line 2055, in 
plot
    ret =  gca().plot(*args, **kwargs)
  File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 2636, in 
plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 267, in 
_grab_next_args
    yield self._plot_1_arg(remaining[0], **kwargs)
  File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 189, in 
_plot_1_arg
    markerfacecolor=color,
  File "/usr/lib64/python2.4/site-packages/matplotlib/lines.py", line 209, in 
__init__
    self.set_data(xdata, ydata)
  File "/usr/lib64/python2.4/site-packages/matplotlib/lines.py", line 265, in 
set_data
    y = ma.ravel(y)
  File "/usr/lib64/python2.4/site-packages/Numeric/MA/MA.py", line 1810, in 
ravel
    d = Numeric.ravel(filled(a))
  File "/usr/lib64/python2.4/site-packages/Numeric/MA/MA.py", line 222, in 
filled
    return Numeric.array(a)
ValueError: cannot handle misaligned or not writeable arrays.


Darren




More information about the Scipy-dev mailing list