[Numpy-discussion] Nasty bug with recarray and cPickle

James Philbin philbinj at gmail.com
Fri Nov 7 09:15:48 EST 2008


Anyone?

James

On Thu, Nov 6, 2008 at 2:53 PM, James Philbin <philbinj at gmail.com> wrote:
> 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