Error with: pickle.dumps(numpy.float32)

Ziga Seilnacht ziga.seilnacht at gmail.com
Wed Aug 16 13:25:27 EDT 2006


Iljya wrote:
> I have reproduced the error with Numpy 1.0b1
>
> The output with v.1.0b1 reads:
> PicklingError: Can't pickle <type 'float32scalar'>: it's not found as
> __builtin__.float32scalar
>
> Has anyone else encountered this?
>
> Thanks,
>
> Iljya
>
> Iljya wrote:
> > Hello,
> >
> > I need to pickle the type numpy.float32 but encounter an error when I
> > try to do so. I am able to pickle the array itself, it is specifically
> > the type that I cannot pickle.
> >
> > I am using:
> > Numpy version: 0.9.4
> > Python version: 2.4.3
> > Windows XP
> >
> > Here is the code that reproduces the error:
> > ______________________________________
> > import numpy
> > import pickle
> >
> > pickle.dumps(numpy.float32)
> >
> > Output:
> > PicklingError: Can't pickle <type 'float32_arrtype'>: it's not found as
> > __builtin__.float32_arrtype
> > ______________________________________
> >
> > Any suggestions would be much appreciated.
> >
> > Thanks,
> >
> > Iljya Kalai

This looks like a numpy bug. It seems that float32_arrtype's name is
incomplete. Its tp_name field should start with a module name, but
since it doesn't, Python assumes that it is a builtin type:

>>> import numpy
>>> numpy.float32.__module__
'__builtin__'

You should report this bug either to the numpy list:
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

or to their bug tracker:
http://projects.scipy.org/scipy/numpy

Ziga




More information about the Python-list mailing list