Skip to content

Add a ticks input parameter #8

@kwgoodman

Description

@kwgoodman

What do you think of adding a ticks parameter to DataArray?

Current behavior:

>>> dar = DataArray([[1, 2], [3, 4]], (('row', ['A','B']), ('col', ['C', 'D'])))
>>> dar.axes
(Axis(label='row', index=0, ticks=['A', 'B']),
 Axis(label='col', index=1, ticks=['C', 'D']))

Proposed ticks as separate input parameter:

>>> DataArray([[1, 2], [3, 4]], labels=('row', 'col'), ticks=[['A', 'B'], ['C', 'D']])

I think this would make it easier for new users to construct a DataArray with
ticks just from looking at the DataArray signature. No magic tuples needed. It would match the
signature of Axis. My use case is to use ticks only and not names axes (at
first), so:
::
>>> DataArray([[1, 2], [3, 4]], ticks=[['A', 'B'], ['C', 'D']])

instead of the current:
::
>>> DataArray([[1, 2], [3, 4]], ((None, ['A','B']), (None, ['C', 'D'])))

It might also cause less typos (parentheses matching) at the command line.

Having separate labels and ticks input parameters would also leave the option
open to allow any hashable object, like a tuple, to be used as a label.
Currently tuples have a special meaning, the (labels, ticks) tuple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions