[Numpy-discussion] returning recarray records as plain arrays
Matthew Koichi Grimes
mkg at cs.nyu.edu
Wed Jan 3 23:57:43 EST 2007
Pierre GM wrote:
> On Wednesday 03 January 2007 15:39, Matthew Koichi Grimes wrote:
>> As per Stefan's help, I've made a subclass of recarray called nnvalue.
>> It just fixes the dtype to [('x', 'f8'), ('dx', 'f8'), ('delta', 'f8)],
>> and adds a few member functions. I basically treat nnvalue as a struct
>> with three equal-shaped array fields: x, dx, and delta.
> Please try to post (pieces of) your code, so that we can have a better idea of
> how to help you.
> Thanks in advance
It's essentially unchanged from Stefan's code:
import numpy as N
dtype = N.dtype([('x','f8'),('dx','f8'),('deltas','f8')])
data = N.zeros(shape,subtype.dtype)
pass # for now
"""Fills all members other than x with zeros."""
self['dx'][:] = 0.
self['deltas'][:] = 0.
More information about the NumPy-Discussion