[Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes
Fri Jul 9 20:44:08 CDT 2010
On Fri, Jul 9, 2010 at 5:26 PM, Keith Goodman <email@example.com> wrote:
> On Fri, Jul 9, 2010 at 6:11 PM, Joshua Holbrook <firstname.lastname@example.org> wrote:
>> I think I like being able to group ticks with their axis, so I know
>> which ticks belong to which axis without having to scan back-and-forth
>> between them to match them up. Do you think you can explain why you
>> would prefer to separate labels and ticks?
> You wouldn't have to know that (labels, ticks) has to be a tuple. If
> you write it is a list [label, tick] it doesn't work. As is, you don't
> have the option to let labels be any hashable object, like tuples
> since tuples have a special meaning.
> It would treat labels and ticks on an equal footing. And it would be
> the same signature as Axis which has separate label and ticks
> parameters. And you could make a tick only DataArray (i.e., no axis
> labels) without writing None for each axis label. That's was my main
> concern since that it what I plan to do at first.
> So I could write:
>>>> DataArray([[1, 2], [3, 4]], ticks=[['A', 'B'], ['C', 'D']])
> instead of
>>>> DataArray([[1, 2], [3, 4]], ((None, ['A','B']), (None, ['C', 'D'])))
> Less likely to have problems with matching parentheses.
> NumPy-Discussion mailing list
It's definitely true that making ticks sans-axes is made much easier this way.
Maybe we can take advantage of zip somehow? Here's what I mean:
In : axes=['row','col']
In : labels=[['a','A'],['b','B']]
In : zip(axes,labels)
Out: [('row', ['a', 'A']), ('col', ['b', 'B'])]
Or, in reverse:
In : zip(*(('row', ['a', 'A']), ('col', ['b', 'B'])))
Out: [('row', 'col'), (['a', 'A'], ['b', 'B'])]
In other words, each method is pretty much a zipped version of the
other, minus some wrapping lists and list<-->tuple things going on.
As an aside, I don't think we'd want to keep the current string
representation of the datarray as-is. I know I don't like it!
More information about the NumPy-Discussion