[Numpy-discussion] Unpickled numarray types unsable?
jmiller at stsci.edu
Mon Jun 21 13:06:04 CDT 2004
On Mon, 2004-06-21 at 14:39, Francesc Alted wrote:
> I'm experiencing problems when using a numarray datatype after
> pickle/unpickle it:
> >>> import numarray
> >>> import pickle
> >>> c=pickle.dumps(numarray.Float64)
> >>> t=pickle.loads(c)
> >>> t
> >>> na=numarray.array(type=t, shape=(2,))
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/local/lib/python2.3/site-packages/numarray/numarraycore.py", line 321, in array
> return NumArray(buffer=sequence, shape=shape, type=type)
> RuntimeError: _numarray_init: can't get typeno for type
> Perhaps this is a bug and the typeno attribute is missed when reconstructing
> the type?
It's a bug in the C-API / implementation of pickling for the type
objects. The C-API keeps references to the type objects which are
assumed to be unique: there is one Float64, just like there is one
None. The pickling produces "functional equivalents" which lose their
identities from the perspective of C. I'm not sure what the fix is yet.
More information about the Numpy-discussion