[Numpy-discussion] another view puzzle

josef.pktd@gmai... josef.pktd@gmai...
Wed Jun 3 15:23:46 CDT 2009


>>> import numpy as np
>>> x = np.array([(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)],
     dtype=[('a', '<f4'), ('b', '<f4'), ('c', '<f4'), ('d', '<f4'),
('e', '<f4')])

>>> xvm = x.view(np.matrix)
>>> xvm
matrix([[(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)]],
       dtype=[('a', '<f4'), ('b', '<f4'), ('c', '<f4'), ('d', '<f4'),
('e', '<f4')])
>>> xvm*2
matrix([[(0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0),
         (1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0)]], dtype=object)
>>>

What am I doing wrong?

Josef


More information about the Numpy-discussion mailing list