[Numpy-discussion] Structured array dtype

Nicolas Rougier Nicolas.Rougier@inria...
Fri Aug 30 10:26:51 CDT 2013


I'm a bit lost with the following example (numpy 1.7.1, osx 10.8):

>>> Z = np.zeros(10, [('a', np.float32, 3), ('b', np.float32, 4)])

>>> Z['a'].dtype

>>> Z.dtype['a']
dtype(('<f4', (3,)))

Does that mean that dtype['a'] is the dtype of field 'a' when in Z, while Z['a'].dtype is the dtype of field 'a' when "extracted" or my way of thinking is totally wrong ?

What bothers me the most is that I cannot do:

>>> Z['a'].view(Z.dtype['a'])
ValueError: new type not compatible with array.


More information about the NumPy-Discussion mailing list