[SciPy-user] How to read legacy scipy.Pickler arrays?

Mark Coletti mcoletti at gmail.com
Mon Mar 24 17:56:05 EDT 2008


I have some old python code that used scipy.Pickler to save arrays to disk.
After installing the new scipy, I get this error:

data_unpickler = scipy.Unpickler( data_file )
AttributeError: 'module' object has no attribute 'Unpickler'

So I went looking for it:

mcoletti at sapient:/usr/local/lib/python2.5/site-packages/scipy> find . -name
"*.py" | xargs grep -H Pickler
./special/tests/Test.py:            p=Numeric.Pickler(f)

Hmm.

Ok, so mebbe I can directly use the pickle module instead?

    time_min_data = data_unpickler.load()
  File "/usr/local/lib/python2.5/pickle.py", line 858, in load
    dispatch[key](self)
KeyError: 'A'


Well, ok.  Maybe not.  Does numpy have a Pickler?

mcoletti at sapient:/usr/local/lib/python2.5/site-packages/numpy> find . -name
"*.py" | xargs grep -H Pickler
./oldnumeric/misc.py:           'Pickler', 'dot', 'outerproduct',
'innerproduct', 'insert']
./oldnumeric/misc.py:class Pickler(pickle.Pickler):
./numarray/session.py:    p = pickle.Pickler(file, protocol=2)

Well, that has potential.  Let's try that:

    data_unpickler = numpy.oldnumeric.Unpickler( data_file )
  File "/usr/local/lib/python2.5/site-packages/numpy/oldnumeric/misc.py",
line 34, in __init__
    raise NotImplemented
TypeError: exceptions must be classes, instances, or strings (deprecated),
not NotImplementedType


Ok, I give up.  What do I need to do to read legacy scipy pickled data?


Cheers,

Mark
-- 
I'm taking reality in small doses to build immunity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080324/8b4cd901/attachment.html>


More information about the SciPy-User mailing list