[Numpy-discussion] Datarray BoF, part2

Vincent Davis vincent@vincentdavis....
Wed Jul 21 14:14:45 CDT 2010


On Wed, Jul 21, 2010 at 1:00 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> On Wed, Jul 21, 2010 at 11:41 AM, Vincent Davis
> <vincent@vincentdavis.net> wrote:
>> On Wed, Jul 21, 2010 at 11:08 AM, Keith Goodman <kwgoodman@gmail.com> wrote:
>>> On Wed, Jul 21, 2010 at 9:56 AM, John Salvatier
>>> <jsalvati@u.washington.edu> wrote:
>>>> I don't really know much about this topic, but what about a flag at array
>>>> creation time (or whenever you define labels) that says whether valid
>>>> indexes will be treated as labels or indexes for that array?
>>>
>>> It's an interesting idea. My guess is that you'd end up having to
>>> check the attribute all the time when writing code:
>>>
>>> if dar.intaslabel:
>>>    dar2 = dar[tickmap(i)]
>>> else:
>>>    dar2 = dar[i]
>>
>> Obviously there are several aspects of a labels that need to be
>> considered. An important on is if an operation breaks the meaning of
>> the labels. I like the idea of tickmap(i) it could have a lot of
>> features like grouping... Maybe even work on structure arrays(maybe).
>> The flag could connect the tickmap() to the array. Then if an
>> operation was performed on the array to would result in the labels no
>> longer being meaningful then the flag would change. In this way
>> tickmap(i) checks for the flags and each axis could have a flag.
>> (I am sure there is lots I am missing)
>
> Each axis currently has a tick map: Axis._tick_dict. From a datarray
> you can access it like this:
>
>>> from datarray import DataArray
>>> x = DataArray([1,2,3], labels=[('time', ['n1', 'n2', 'n3'])])
>>> x.axis.time._tick_dict
>   {'n1': 0, 'n2': 1, 'n3': 2}
>>> x.axes[0]._tick_dict
>   {'n1': 0, 'n2': 1, 'n3': 2}
>>> x.axis['time']._tick_dict
>   {'n1': 0, 'n2': 1, 'n3': 2}

I was thinking of a more universal tickmap(). Something where I can
define the map/lables ie
labels=[('time', ['n1', 'n2', 'n3'])])

And apply it to any array of the right size. That is I don't make a
special array (DataArray). Then the problem becomes know if the labels
are sill valid after other functions operate on the array. So this is
where I was thinking of having a flag (array attribute?) This could
just be left to the user.
My only point here is a universal tickmap() function might be nice.

Vincent

>
> On a separate note, I think having both axis and axes attribute is
> confusing. Would it be possible to only have one of them? Here's a
> proposal: http://github.com/fperez/datarray/commit/01b2d3d2082ade38ec89dbca0c070dd4fc9d9ca3#L1R330
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list