[Numpy-discussion] Issue with dtype and nx1 arrays

Warren Weckesser warren.weckesser@enthought....
Tue Aug 30 22:42:27 CDT 2011


On Tue, Aug 30, 2011 at 10:34 PM, Thomas Robitaille <
thomas.robitaille@gmail.com> wrote:

> Hello,
>
> Is the following behavior normal?
>
> In [1]: import numpy as np
>
> In [2]: np.dtype([('a','<f4',2)])
> Out[2]: dtype([('a', '<f4', (2,))])
>
> In [3]: np.dtype([('a','<f4',1)])
> Out[3]: dtype([('a', '<f4')])
>
> I.e. in the second case, the second dimension of the dtype (1) is
> being ignored? Is there a way to avoid this?
>


Use a tuple to specify the dimension:

In [11]: dtype([('a', '<f4', (2,))])
Out[11]: dtype([('a', '<f4', (2,))])

In [12]: dtype([('a', '<f4', (1,))])
Out[12]: dtype([('a', '<f4', (1,))])


Warren



>
> Thanks,
> Thomas
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110830/b13b79d6/attachment.html 


More information about the NumPy-Discussion mailing list