def numpy_array_from_structure(items, fmt, t):
 (memlen, itemsize, ndim, shape, strides, offset) = t
 buf = bytearray(memlen)
 for (j, v) in enumerate(items):
  struct.pack_into(fmt, buf, (j * itemsize), v)
 return numpy_array(buffer=buf, shape=shape, strides=strides, dtype=fmt, offset=offset)

def numpy_array_from_structure ( items , fmt , t ) : ( memlen , itemsize , ndim , shape , strides , offset ) = t buf = bytearray ( memlen ) for ( j , v ) in enumerate ( items ) : struct . pack_into ( fmt , buf , ( j * itemsize ) , v ) return numpy_array ( buffer = buf , shape = shape , strides = strides , dtype = fmt , offset = offset )
return numpy_array from the tuple returned by rand_structure() .