[Numpy-discussion] Re: Dumping record arrays
Travis Oliphant
oliphant.travis at ieee.org
Sat Apr 22 10:19:00 EDT 2006
Jordi Bofill wrote:
> 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')
>>
>>
This is fixed in SVN (but you have to get more than just the SVN
records.py script). The needed change is in the __reduce__ method of
the array object (which is in C). A re-compile is needed.
NumPy 0.9.8 should be out in a few weeks.
Best,
-Travis
>> 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'))
>
>
>
>
>
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list