BIDS / datarray

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

Integer labels aren't currently allowed #43

Closed fperez closed 13 years ago

fperez commented 13 years ago

The current implementation explicitly refuses integer labels, but multiple parties have expressed that this would be a very important feature to have. We've thought that it could be implemented by leaving all normal indexing operations to treat integers like python/numpy do already, but having a .lix 'label integer' indexing attribute that interprets its integer arguments as labels instead and translates them.

The current behavior is:

In [131]: t = DataArray(array([100,200,300]), [['x', ['10','20','-5']]])

In [132]: t['-5']
Out[132]: 300

But if we allow integer labels, this would work:

In [131]: t = DataArray(array([100,200,300]), [['x', [10,20,-5]]])

In [132]: t.lix[-5]
Out[132]: 300

In [132]: t.axis.x.lix[-5]
Out[132]: 300

t[-5] -> would give an error, it  would treat -5 like a normal from-the-end index
terhorst commented 13 years ago

Closed as per the recent DataArray sprint.