[Numpy-discussion] Question about dtype
Valentin Haenel
valentin at haenel.co
Fri Dec 26 20:03:34 EST 2014
Hi,
* Sebastian <sebix at sebix.at> [2014-12-13]:
> I'll just comment on the creation of your dtype:
>
> > dt = [("<f8", "<f8")]
>
> You are creating a dtype with one field called '<f8' and with type '<f8':
>
> >>> dt = [("<f8", "<f8")]
> >>> dty = np.dtype(dt)
> >>> dty.names
>
> ('<f8',)
>
> What you may want are two fields with type '<f8' and without fieldname:
>
> >>> dt = [("<f8", "<f8")]
> >>> dty = np.dtype(('<f8,<f8'))
> >>> dty.names
>
> ('f0', 'f1')
> >>> dty.descr
>
> [('f0', '<f8'), ('f1', '<f8')]
Apologies for this oversight on my part. You are right of course. I
chose my example badly.
Perhaps I should have chosen:
arr = numpy.array([('a', 1), ('b', 2)], dtype=[('a', 'S1'), ('b',
'f8')])
V-
More information about the NumPy-Discussion
mailing list