[Numpy-discussion] Datarray BoF, part2

Keith Goodman kwgoodman at gmail.com
Wed Jul 21 17:48:46 EDT 2010


On Wed, Jul 21, 2010 at 2:32 PM, Rob Speer <rspeer at 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.



More information about the NumPy-Discussion mailing list