[Numpy-discussion] Possible conversion bug with record array

Nicolas Rougier Nicolas.Rougier at inria.fr
Wed May 22 13:07:47 EDT 2013



Hi all,

I got a weird output from the following script:

import numpy as np

U = np.zeros(1, dtype=[('x', np.float32, (4,4))])

U[0] = np.eye(4)
print U[0]
# output:  ([[0.0, 1.875, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.875], [0.0, 0.0, 0.0, 0.0]],)

U[0] = np.eye(4, dtype=np.float32)
print U[0]
# output:  ([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]],)


The first output is obviously wrong. Can anyone confirm ?
(using numpy 1.7.1 on osx 10.8.3)


Nicolas


More information about the NumPy-Discussion mailing list