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

Keith Goodman kwgoodman at gmail.com
Fri Jul 9 20:56:12 EDT 2010


On Fri, Jul 9, 2010 at 5:52 PM, Joshua Holbrook <josh.holbrook at gmail.com> wrote:
> On Fri, Jul 9, 2010 at 4:22 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
>> On Fri, Jul 9, 2010 at 5:00 PM, Christopher Barker
>> <Chris.Barker at noaa.gov> wrote:
>>> Keith Goodman wrote:
>>>> On Fri, Jul 9, 2010 at 4:05 PM, Christopher Barker
>>>> <Chris.Barker at noaa.gov> wrote:
>>>>
>>>>> So what would you get if you wanted:
>>>>>
>>>>> MyDataArray['jones':'wilson']
>>>>>
>>>>> or
>>>>>
>>>>> MyDataArray.names[slice('jones','wilson')]
>>>>>
>>>>> or whatever the syntax would be?
>>>>>
>>>>> If it was in alphabetical order, you'd be all set, but what it if
>>>>> wasn't? It would be pretty cool if you could get an alphabetical slice.
>>>>
>>>> If it sorted the data automatically then you couldn't turn off the
>>>> sorting.
>>>
>>> sure -- but what would it mean to ask for a slice by name without
>>> sorting? If you want it in the order it happens to be in, you'd use
>>> numerical slicing (at least that's the use case I can imagine).
>>
>> That is true. It would just save you from having to look up the index value.
>>
>> Another handy method would take tick and axis as input and return the index:
>> http://larry.sourceforge.net/reference.html#la.larry.labelindex
>>
>>>> Without automatic sorting the user gets to decide whether or
>>>> not to sort before indexing. A sort ticks along axis function would be
>>>> useful, sort of like
>>>> http://larry.sourceforge.net/reference.html#la.larry.sortaxis.
>>>
>>> Yup -- that's nice, and would take care of most issues.
>>>
>>> -Chris
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Christopher Barker, Ph.D.
>>> Oceanographer
>>>
>>> Emergency Response Division
>>> NOAA/NOS/OR&R            (206) 526-6959   voice
>>> 7600 Sand Point Way NE   (206) 526-6329   fax
>>> Seattle, WA  98115       (206) 526-6317   main reception
>>>
>>> Chris.Barker at noaa.gov
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>
> Idea: What if we specified axes/ticks like this (using a 2-d example I
> made up for myself):
>
> punnet=DataArray([[1,2],[2,4]], {'row': ['a','A'], 'column': ['a','A']})
>
> That is, use a dictionary instead of nested tuples or separate lists?

It is easier to read than the current tuple of labels, ticks. But
dictionaries are not ordered. So there is no way for the user to
control the ordering of the axes in your example. But I'm just saying
that because I'd like to have separate labels and ticks :)



More information about the NumPy-Discussion mailing list