[Numpy-discussion] metadata and metabehavior for arrays (for scipy.base or Numeric3)
cjw at sympatico.ca
cjw at sympatico.ca
Wed Apr 6 08:16:33 CDT 2005
Sébastien de Menten wrote:
>>> 1) attaching a physical unit to array data (see for instance Unum
>>> http://home.tiscali.be/be052320/Unum.html )
>>> 2) description of axis (see
>>> http://sourceforge.net/mailarchive/message.php?msg_id=11051806).
>>> Very useful to manipulate easily time series.
>>
>>
>> Does the record array provide a means of addressing this need?
>>
>
> Not really, when I mean axis, I speak about indexing.
Fair enough, I was thinking one dimensionally.
> For an array (named a) with shape (10, 5, 33), I would like to attach
> 3 arrays or list or tuple (named axis_information[0],
> axis_information[1] and axis_information[2]) of size (10,), (5,) and
> (33,) which give sense to the first, second and third index.
> For instance,
> A[i,j,k] => means the element of A at (axis_information[0][i],
> axis_information[1][j], axis_information[2][k])
> instead of
> A[i,j,k] => means the element of A at index position [i,j,k] which
> makes less sense (you always need to track the meaning of i,j,k in
> parallel).
>
>>> 3) masked arrays as in MA module of Numeric
>>
>
> Maybe this one could be implemented using record array with a record
> like (data, mask).
> However, it would be cumbersome to use.
> E.g. a.field("data")[:] = cos( a.field("data")[:] )
> instead of
> a[:] = cos(a[:])
> with the current MA module
Assuming "data" is the name of a field in a record array "a", why not
have a.data to represent a view (or copy, depending on the convention
adopted) of a column in a or
a.data.Cos to provide the cosines of the values in the data column?
"Cos" is used in place of "cos" to distinguish the method from the
function. The former requires no parentheses.
This assumes that the values in data are of the approriate numerictype (
with its appropriate typecode).
Colin W.
>
>
>>> 4) arrays for interval arithmetic where one keep another array with
>>> precision of data
>>> 5) record arrays (currently being integrated in scipy.base as a base
>>> type)
>>>
>> Yes, and there is numarray's array of objects.
>>
>
> This is overkilling as it eats way too much memory.
> E.g. your data represents instantaneous speeds and so it tagged with a
> "m/s" information (a complex object) valid for the full array.
> Distributing this information to each component of an array via an
> array object is not practical.
>
More information about the Numpy-discussion
mailing list