Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow positional indexing with unsigned integer types #1544

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Bug fixes
objects with data stored as ``dask`` arrays (:issue:`1529`).
By `Joe Hamman <https://github.com/jhamman>`_.

- Fix positional indexing to allow the use of unsigned integers (:issue:`1405`).
By `Joe Hamman <https://github.com/jhamman>`_ and
`Gerrit Holl <https://github.com/gerritholl`_.

.. _whats-new.0.9.6:

v0.9.6 (8 June 2017)
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def canonicalize(indexer):
'1d arrays')
if indexer.dtype.kind == 'b':
indexer, = np.nonzero(indexer)
elif indexer.dtype.kind != 'i':
elif indexer.dtype.kind not in {'i', 'u'}:
raise ValueError('invalid subkey %r for integer based '
'array indexing; all subkeys must be '
'slices, integers or sequences of '
Expand Down
5 changes: 5 additions & 0 deletions xarray/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def test_indexer(data, x, expected_pos, expected_idx=None):
[True, True, True, True, False, False, False, False],
pd.MultiIndex.from_product([[1, 2], [-1, -2]]))

def test_uint_indexer(self):
# regression test for #1405
da = DataArray([1, 2, 3], dims='x')
da.isel(x=np.array([0], dtype="uint64"))


class TestLazyArray(TestCase):
def test_slice_slice(self):
Expand Down