[Numpy-discussion] Properties of fields in numpy
Travis Oliphant
oliphant at ee.byu.edu
Mon Feb 6 16:09:02 EST 2006
Francesc Altet wrote:
>Hi,
>
>I don't specially like the 'void*' typecasting that are receiving the
>types in fields in situations like:
>
>In [143]:dtype = numpy.dtype([
> .....: ('x', '<i4', (2,)),
> .....: ('Info',[
> .....: ('name', '<U120'),
> .....: ('weight', '<f4')])])
>
>In [147]:dtype.fields['x'][0].name
>Out[147]:'void64'
>
>were you can see that we have lost the information about the native type
>of the 'x' field. Rather, I'd expect something like:
>
>
In SVN of numpy, the dtype objects now have a .base attribute and a
.shape attribute.
The .shape attribute returns (1,) or the shape of the sub-array.
The .base attribute returns the data-type object of the base-type, or a
new reference to self, if the object has no base.type.
Thus, in current SVN
dtype['x'].base.name would always give you what you want.
-Travis
More information about the NumPy-Discussion
mailing list