[Numpy-discussion] Datarray BoF, part2

Skipper Seabold jsseabold@gmail....
Wed Jul 21 17:00:51 CDT 2010


On Wed, Jul 21, 2010 at 5:48 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> On Wed, Jul 21, 2010 at 2:32 PM, Rob Speer <rspeer@mit.edu> wrote:
>> I agree with the idea that axis labels must be strings.
>>
>> Yes, this is the opposite of my position on tick labels ("names"), but
>> there's a reason: ticks are often defined by whatever data you happen
>> to be working with, but axis labels will in the vast majority of
>> situations be defined by the programmer as they're writing the code.
>> If the programmer wants to name something, they'll certainly be able
>> to do so with a string.
>
> What started the discussion was that someone wanted to have more than
> one label name for one axis. So I suggested that if we allow any
> hasable objects as axis label then, for example, a tuple could be used
> to hold multiple names.
>
> That would also allow a datarray to be flattened to 1d since the axis
> labels could be combined into a tuple. So a 2d datarray with axis
> names "time" and "distance" and ticks 't1', 't2' and 'd1', 'd2' could
> flatten to
>
> axis --> ('time', 'distance')
> ticks --> [('t1', 'd1'), ('t1', 'd2'), ('t2', 'd1'), ('t2', 'd2')]
>
> An unflatten function along with a fill value could unflatten the datarray.

I'm not doing the work, so really whatever works for people, but

In [1]: '_'.join(('time','distance'))
Out[1]: 'time_distance'

would also work in this case, though I guess we get into trouble for
unflatten when individual axis labels have an underscore in them.

Skipper


More information about the NumPy-Discussion mailing list