Thanks, I filed a new issue on the bug tracker. Nicolas On May 22, 2013, at 8:15 PM, eat <e.antero.tammi@gmail.com> wrote:
Hi,
FWIW, apparently bug related to dtype of np.eye(.)
On Wed, May 22, 2013 at 8:07 PM, Nicolas Rougier <Nicolas.Rougier@inria.fr> wrote:
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) In []: sys.version Out[]: '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' In []: np.__version__ Out[]: '1.6.0' In []: U= np.zeros(1, dtype= [('x', np.float32, (4, 4))])
In []: U[0]= np.eye(4) In []: U Out[]: array([ ([[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]],)], dtype=[('x', '<f4', (4, 4))])
In []: U[0]= np.eye(4, dtype= np.float32) In []: U Out[]: array([ ([[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]],)], dtype=[('x', '<f4', (4, 4))])
and In []: sys.version Out[]: '3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]' In []: np.__version__ Out[]: '1.7.0rc1' In []: U= np.zeros(1, dtype= [('x', np.float32, (4, 4))])
In []: U[0]= np.eye(4) In []: U Out[17]: array([ ([[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]],)], dtype=[('x', '<f4', (4, 4))])
U[0]= np.eye(4, dtype= np.float32)
In []: U Out[]: array([ ([[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]],)], dtype=[('x', '<f4', (4, 4))])
My 2 cents, -eat
Nicolas _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion