[Numpy-discussion] Proposed record array behavior: the rest of the story: updated

Francesc Alted falted at pytables.org
Wed Jul 28 03:01:23 EDT 2004


A Dimarts 27 Juliol 2004 22:04, gerard.vermeulen at grenoble.cnrs.fr va escriure:
> Introducing recordArray["column"] as an alternative for
> recordArray.field("column") breaks a symmetry between for instance 1-d
> record arrays and 2-d normal arrays. (the symmetry is strongly suggested
> by their representation: a record array prints almost as a list of tuples
> and a 2-d normal array almost as a list of lists).
> 
> Indexing a column of a 2-d normal array is done by normalArray[:, column],
> so why not recArray[:, "column"] ?

Well, I must recognize that this has its beauty (by revealing the simmetry
that you mentioned). However, mixing integer and strings on indices can
be, in my opinion, rather confusing for most people. Then, I guess that
the implementation wouldn't be easy.

> I prefer to use
> 
> recordArray.column[32]
> 
> and/or
> 
> recordArray[32].column
> 
> rather than recordArray["column"][32].

I would prefer better:

recordArray.fields.column[32]

or

recordArray.cols.column[32]

(note the use of the plural in fields and cols, which I think is more
consistent about its functionality)

The problem with:

recordArray[32].fields.column

is that I don't see it as natural and besides, completion capabilities
would be broken after the [] parenthesis.

Anyway, as Russell suggested, I don't like recordArray["column"][32],
because it would be unnecessary (you can get same result using
recordArray[column_idx][32]).

Although I recognize that a recordArray.cols["column"][32] would not hurt
my eyes so much. This is because although indices continues to mix ints
and strings, the difference is that ".cols" is placed first, giving a new
(and unmistakable) meaning to the "column" index. 

Cheers,

-- 
Francesc Alted





More information about the NumPy-Discussion mailing list