[Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

Lluís xscript at gmx.net
Thu Jul 8 13:03:47 EDT 2010


Rob Speer writes:

> On Thu, Jul 8, 2010 at 7:13 AM, Lluís <xscript at gmx.net> wrote:
>> Thus, we can use something in the middle:
>> 
>>   arr[0,1]
>>   arr.names['Netherlands',2010] # I'd rather go for 'names' instead of 'ticks'

> Ah ha. So this is the case with positional axes but named ticks, which
> we haven't really brought up yet. I'm definitely thinking of making
> the top-level datarray support "named" as well, which would make it
> into:
>>>> arr.named('Netherlands', 2010)

> But the other change you've got here is to make "named" into a
> __getitem__-able object instead of a method, so you use square
> brackets with it and can use slice syntax. I could do it this way as
> well.

Right, seamless slicing is precisely why I have __getitem__.


> But I don't understand your second example:
>>   arr.country['Spain'].year[1994:2010]

> That seems to run straight into the index/name ambiguity. Shouldn't
> that take the 1994th through 2010th indices along the "year" axis? Not
> every axis will have names, so you can't make *all* the indexing go by
> names.

Sorry, I just c&p without placing the necessary '.


> If named were a getitem-able object, that would be:
>>>> arr.country.named['Spain'].year.named[1994:2010]

Or what I was striving for:

   arr.year.named[1994:2010]
   arr.year['1994':'2010']
   arr.year['1994':-3]

I already have the code for managing all kinds of indexind methods in sciexp2,
so I you want I could try to integrate it into datarray.

Read you,
     Lluis

-- 
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth



More information about the NumPy-Discussion mailing list