[Numpy-discussion] Re: Dumping record arrays

Jordi Bofill jordi.bofill at upc.edu
Sat Apr 22 09:46:00 CDT 2006


Pierre GM wrote:

> Folks,
> I'd like to dump/pickle some record arrays. The pickling works, the
> unpickling raises a ValueError (on my version of numpy 0.9.6). (cf below).
> Is this already corrected in the svn version ?
> Thx
> 
> 
>
###########################################################################
> #
> 
> x1 = array([21,32,14])
> x2 = array(['my','first','name'])
> x3 = array([3.1, 4.5, 6.2])
> r = rec.fromarrays([x1,x2,x3], names='id, word, number')
> 
> r.dump('dumper')
> rb=load('dumper')
> ---------------------------------------------------------------------------
> exceptions.ValueError                                Traceback (most
> recent call last)
> 
> /home/backtopop/Work/workspace-python/pyflows/src/<ipython console>
> 
> /usr/lib64/python2.4/site-packages/numpy/core/numeric.py in load(file)
>     331     if isinstance(file, type("")):
>     332         file = _file(file,"rb")
> --> 333     return _cload(file)
>     334
>     335 # These are all essentially abbreviations
> 
> /usr/lib64/python2.4/site-packages/numpy/core/_internal.py in
> _reconstruct(subtype, shape, dtype)
>     251
>     252 def _reconstruct(subtype, shape, dtype):
> --> 253     return ndarray.__new__(subtype, shape, dtype)
>     254
>     255
> 
> ValueError: ('data-type with unspecified variable length', <function
> _reconstruct at 0x2aaaafcf1578>, (<class 'numpy.core.records.recarray'>,
> (0,), 'V'))
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language that extends applications into web and mobile media. Attend the
> live webcast and join the prime developer group breaking into this new
> coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

I'm newbie moving from numarray and I also get this error. I tried svn
records.py with the same result. Any hope in getting it fixed?
The error can be reproduce from the source example:

import  numpy.core.records as rec
r=rec.fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3')
import cPickle
print cPickle.loads(cPickle.dumps(r))
---------------------------------------------------------------------------
exceptions.ValueError                                Traceback (most recent
call last)

/home/jordi/temp/<ipython console>

/usr/lib/python2.4/site-packages/numpy/core/_internal.py in
_reconstruct(subtype, shape, dt ype)
    251
    252 def _reconstruct(subtype, shape, dtype):
--> 253     return ndarray.__new__(subtype, shape, dtype)
    254
    255

ValueError: ('data-type with unspecified variable length', <function
_reconstruct at 0xb78f ce64>, (<class 'numpy.core.records.recarray'>,
(0,), 'V'))









More information about the Numpy-discussion mailing list