On Thu, Oct 7, 2010 at 10:09, Ioan Ferencik <ioan.feren...@tkk.fi> wrote: > Hello Robert, > > I dare to bother you again with some questions. > > this time I have a numpy array with fields > ar = array([(1.0, 2.0, 3, 4), (2.0, 3.0, 4, 5)], dtype={'names': > ['q','wl','cssid','br'], 'formats':['f4', 'f4', 'i4', 'i4'], > 'offsets': [0, 4, 8, 12]}, order='F') > > on C API I want to match this struct > typedef struct val1{ > float q; > float wl; > int cssid; > int br; > }hm1dval1; > > to an element of this array > I get the array object, i can see the fields. The type of the array > elements is Pyarray_VOID > > however following code gives me a segfault > > hm1dval1 **s = PyArray_DATA(ao);
Since this is *not* an object array but an array of hm1dval1 structs, you declare it like so: hm1dval1 *s = PyArray_DATA(ao); -- Robert Kern "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 _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion