BIDS / datarray

Prototyping numpy arrays with named axes for data management.
http://bids.github.com/datarray
Other
87 stars 20 forks source link

NF: add string and slice slicing of AxesManager #68

Open matthew-brett opened 8 years ago

matthew-brett commented 8 years ago

After this PR, you can do the following two slicing operations, that previously raised errors:

>>> da = DataArray(np.ones((2, 3, 4)), 'abc')
>>> da.axes['b']
Axis(name='b', index=1, labels=None)
>>> da.axes[1:]
(Axis(name='b', index=1, labels=None), Axis(name='c', index=2,
labels=None))

Note that, as currently written, these two both return an Axis:

>>> da.axes['b']
Axis(name='b', index=1, labels=None)
>>> da.axes('b')
Axis(name='b', index=1, labels=None)
matthew-brett commented 8 years ago

Thinking about it - I am ambivalent about this change. It's a bit annoying that there are now two ways to get an axis by name, and you can always to the slicing by iterating over the axes.