[Numpy-discussion] dtype confusion

Jan Strube curiousjan@gmail....
Mon Mar 26 03:05:32 CDT 2007

I'm afraid I'm not quite done with this, yet.
There's still more I am confused about, even after reading the manual
There is something fundamentally weird about record arrays, that doesn't
seem to click with me.
Please have a look at this piece of code:

import numpy as N
newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)])
x = N.zeros((10, 3))
x.dtype = newtype
print x

x = N.zeros((10, 3), dtype=newtype)
print x

I think I understand what's going on here:
x = N.zeros((10, 1), dtype=newtype)
print x

So can I summarize that in the first case a (10,3) array is reinterpreted (
numpy.view) as a record array, while in the second case I am actually
requesting a (10,3) array of the dtype, which itself has 3 elements?
And the record array should not be viewed as a column-wise array with named
columns (although it can be accessed that way), but rather as an array that
groups the columns in each row into a record. Because after turning it into
a record array, x is still c-contiguous and not fortran-contiguous...

Maybe I'm actually starting to understand this a bit.

Anyways, thanks for listening ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070326/d2b169cf/attachment.html 

More information about the Numpy-discussion mailing list