[Numpy-discussion] record array with array elements
Tue Jan 6 15:41:49 CST 2009
On Tue, Jan 6, 2009 at 14:07, Igor Sylvester <firstname.lastname@example.org> wrote:
> Shouldn't the itemsize below be 2?
>>>> import numpy as np
>>>> dtype = np.dtype( [ (((2,), 'top'), [('nested', 'i1')]) ] )
> The elements of the dtype are of type array of size 2. Each element is a
> (nested) record array of size 2 with one field of type 'i1'. In contiguous
> memory, this should look identical to an 'i1' array of size 2.
That's not a valid dtype. Array fields should be of the form (name,
subdtype, shape), not ((shape, name), subdtype). I'm not sure why
dtype() does not simply reject this input.
In : np.dtype([('top', [('nested', 'i1')], (2,))]).itemsize
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion