[Numpy-tickets] [NumPy] #952: Pickling an element of a recarray is silently broken

NumPy numpy-tickets@scipy....
Fri Nov 7 11:02:45 CST 2008


#952: Pickling an element of a recarray is silently broken
------------------------+---------------------------------------------------
 Reporter:  philbinj    |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:  1.3.0   
Component:  numpy.core  |     Version:  none    
 Severity:  major       |    Keywords:          
------------------------+---------------------------------------------------
 As per the summary. Unpickling a pickled recarray element returns garbage
 data.

 With numpy.__version__=='1.3.0.dev5883':

 {{{
 In [1]: import numpy as np

 In [2]: dtype = [('r','f4'),('g','f4'),('b','f4')]

 In [3]: arr = np.ones((10,), dtype=dtype)

 In [4]: arr
 Out[4]:
 array([(1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, 1.0),
       (1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, 1.0),
       (1.0, 1.0, 1.0), (1.0, 1.0, 1.0)],
      dtype=[('r', '<f4'), ('g', '<f4'), ('b', '<f4')])

 In [5]: arr[0]
 Out[5]: (1.0, 1.0, 1.0)

 In [6]: import cPickle; cPickle.loads(cPickle.dumps(arr[0]))
 Out[6]: (0.0, 0.0, 1.8643547392640242e-38)
 }}}

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/952>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list