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 the gaps. For example: In [118]: ra=numpy.rec.array("1"*300, dtype=[('sval','<a4'),('unused','|V4'), ('dval','<f8')], shape=2) In [119]: ra['sval'] Out[119]: recarray([1111, 1111], dtype='|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='|V4') Cheers, -- >0,0< Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data "-" ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion