[Numpy-discussion] Nasty bug with recarray and cPickle

James Philbin philbinj@gmail....
Thu Nov 6 08:53:27 CST 2008


Hi,

I might be doing something stupid so I thought i'd check here before
filing a bug report.
Firstly:
In [8]: np.__version__
Out[8]: '1.3.0.dev5883'

Basically, pickling an element from a recarray seems to break silently:
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)


Thanks,
James


More information about the Numpy-discussion mailing list