[Numpy-discussion] dtype.type for structured arrays
Fri Aug 6 19:07:21 CDT 2010
On Jul 24, 2010, at 2:42 PM, Thomas Robitaille wrote:
> If I create a structured array with vector columns:
>>>> array = np.array(zip([[1,2],[1,2],[1,3]]),dtype=[('a',float,2)])
> then examine the type of the column, I get:
> Then, if I try and view the numerical type, I see:
> <type 'numpy.void'>
> I have to basically do
> to get what I need. I seem to remember that this used not to be the case, and that even for vector columns, one could access array.dtype.type to get the numerical type. Is this a bug, or deliberate?
This looks the same as I remember it. The dtype is a structured array with the filed name 'a' having an element which is a vector of floats. As a result, the first dtype extracts the vector of floats dtype. This must be type "void" because it is a vector of floats. To get to the underlying type, you have to do what you did. I don't see how it would have worked another way in the past.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion