[Numpy-discussion] another view puzzle
josef.pktd at gmail.com
josef.pktd at gmail.com
Wed Jun 3 16:23:46 EDT 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