From: Francesc A. <fa...@ca...> - 2006-09-15 14:40:48
|
A Divendres 15 Setembre 2006 16:13, Martin Wiechert va escriure: > Hi list, > > I'm using PyArray_DescrConverter with a dict object to create a > "struct-like" dtype from C. > As the struct contains different data types I run into "unaligned access" > problems. > Is there a way to force alignment or to get trailing unused bytes in the > dtpye? One possible solution is to declare void ('V' charcode) types for filling t= he=20 gaps. For example: In [118]: ra=3Dnumpy.rec.array("1"*300, dtype=3D[('sval','<a4'),('unused','= |V4'), ('dval','<f8')], shape=3D2) In [119]: ra['sval'] Out[119]: recarray([1111, 1111], dtype=3D'|S4') In [120]: ra['dval'] Out[120]: array([ 9.73041595e-72, 9.73041595e-72]) You can still access the empty spaces if you want (although it is nonsense): In [121]: ra['unused'] Out[121]: recarray([1111, 1111], dtype=3D'|V4') Cheers, =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" |