[Numpy-discussion] Unnecessary axes in recarrays

Ravi lists_ravi@lavabit....
Tue Feb 10 10:13:36 CST 2009


Hi,
  Recarrays seem to sprout extra axes when they are nested:

----
In [98]: np.__version__
Out[98]: '1.2.0'

In [99]: d1 = dtype( [ ('a',uint8,2), ('b',uint8,1) ] )

In [100]: d2 = dtype( [ ('c',uint8,1), ('d',d1,1) ] )

In [101]: d3 = dtype( [ ('c',uint8,1), ('d',d1,2) ] )

In [102]: a1 = zeros( (4,), dtype=uint8 ).view( d2 )

In [103]: a1['d'].shape
Out[103]: (1,)

In [104]: a2 = zeros( (7,), dtype=uint8 ).view( d3 )

In [105]: a2['d'].shape
Out[105]: (1, 2)

In [106]: d4 = dtype( [ ('c',uint8,1), ('d',d1,(1,1)) ] )

In [107]: zeros( (4,), dtype=uint8 ).view( d2 )[ 'd' ].shape
Out[107]: (1,)
----

Why does d3 field 'd' have an extra axis? And why does d4 field 'd' have only 
one axis?

Regards,
Ravi





More information about the Numpy-discussion mailing list