FW: [Numpy-discussion] Questions about records
hsu at stsci.edu
Fri Apr 2 13:30:05 EST 2004
> >--> arr1 = num.arange(4, shape=(1,2,2), type=num.Float64)
> >--> arr2 = num.arange(4, shape=(1,2,2), type=num.Float64)+10
> >--> a = rec.array([arr1, arr2], names="a,b")
> But is there any advantage to that compared to just using named
> arrays of the desired shape:
> a = num.arange(4, shape=(2,2), type=num.Float64)
> b = num.arange(4, shape=(2,2), type=num.Float64)+10
Not really, in this particular example.
> >I'd be interested in your application as to why a 2x2 table is necessary.
> Here are two different uses I've come up with (both related to image
You need it because you need to pass it to the C-structure, I think. In any
case, you have found a way to get around the problem by using setshape. I'll
take a look of the module to get an idea of how much effort is needed to make
the 2-D (and higher) record arrays to work more smoothly.
More information about the NumPy-Discussion