[Numpy-discussion] PEP: named axis (was: Selection of only a certain number of fields)

Gael Varoquaux gael.varoquaux at normalesup.org
Thu Feb 5 18:16:18 EST 2009


On Thu, Feb 05, 2009 at 05:08:49PM -0600, Travis E. Oliphant wrote:
> I've been fairly quiet on this list for awhile due to work and family 
> schedule, but I think about how things can improve regularly.    One 
> feature that's been requested by a few people is the ability to select 
> multiple fields from a structured array.

Hey Travis,

I have no opinion on the above, as I don't have this use case. However, as
you are talking about implementing something, I jump on the occasion to
suggest another gadget, slightly related: I would like named axis.
Suppose you have a 5D array, I would like to be able to give each axis
names, eg (to chose an example you might be familiar with) ('Frontal',
'Lateral', 'Axial', 'Time', 'Subjects'). And if this could be understood
be numpy operations (say ufuncs and fancy indexing) so that I could do (a
is my 5D array):

>>> b = a.mean(axis='Time')
>>> b.axis
('Frontal', 'Lateral', 'Axial', 'Subjects')

I believe this would make a big difference for people working with
n-dimensional arrays, where n is large.

I do realize this is probably a lot of work, this is why I had been
refraining from mentioning it. I don't feel I can implement this.

Cheers,

Gaël



More information about the NumPy-Discussion mailing list