[Numpy-discussion] converting standard array to record array

Bryce Ready bryce.ready at gmail.com
Tue Aug 30 16:34:18 EDT 2011


Hello all,

So i'm using numpy 1.6.0, and trying to convert a (4,4) numpy array of dtype
'f8' into a record array of this dtype:

dt = np.dtype([('mat','(4,4)f8')])
>

Here is the code snippet:

In [21]: a = np.random.randn(4,4)
>
> In [22]: a.view(dt)
>

and the resulting error:

ValueError: new type not compatible with array.
>

Can anyone shed some light for me on why this conversion is not possible?
It is certainly technically possible, since the memory layout of the two
arrays should be the same.

Can anyone recommend a better way to do this conversion?

Thanks in advance!

-Bryce Ready
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110830/b7c54fee/attachment.html>


More information about the NumPy-Discussion mailing list