Repository: dask/dask

Issue:
Indexing dask.array by an unsigned-integer np.ndarray
Indexing dask.array by an unsigned-integer np.ndarray raises TypeError.
Is it an intended behavior?

```python
In [1]: import numpy as np
   ...: import dask.array as da
   ...: 
   ...: array = da.from_array(np.arange(6), chunks=3)
   ...: array[np.array([0])]  # indexing works with integer array
   ...: 
Out[1]: dask.array<getitem, shape=(1,), dtype=int64, chunksize=(1,)>

In [2]: array[np.array([0], dtype=np.uint64)]  # not with uint array
   ...: 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-6161ebf9f837> in <module>()
----> 1 array[np.array([0], dtype=np.uint64)]  # not with uint array

~/anaconda3/envs/xarray/lib/python3.5/site-packages/dask/array/core.py in __getitem__(self, index)
   1197             return self
   1198 
-> 1199         dsk, chunks = slice_array(out, self.name, self.chunks, index)
   1200 
   1201         dsk2 = sharedict.merge(self.dask, (out, dsk))

~/anaconda3/envs/xarray/lib/python3.5/site-packages/dask/array/slicing.py in slice_array(out_name, in_name, blockdims, index)
    140     """
    141     index = replace_ellipsis(len(blockdims), index)
--> 142     index = tuple(map(sanitize_index, index))
    143 
    144     blockdims = tuple(map(tuple, blockdims))

~/anaconda3/envs/xarray/lib/python3.5/site-packages/dask/array/slicing.py in sanitize_index(ind)
     76                              first_err)
     77     else:
---> 78         raise TypeError("Invalid index type", type(ind), ind)
     79 
     80 

TypeError: ('Invalid index type', <class 'numpy.ndarray'>, array([0], dtype=uint64))
```

python 3.5
dask 0.15.2

originally raised in an [xarray issue](https://github.com/pydata/xarray/issues/1405).

Discussion:
fujiisoup: Thanks for the review. 
Done.

Patch:
diff --git a/dask/array/slicing.py b/dask/array/slicing.py
index 269ffbc49..42e65cc45 100644
--- a/dask/array/slicing.py
+++ b/dask/array/slicing.py
@@ -62,7 +62,7 @@ def sanitize_index(ind):
             # If a 1-element tuple, unwrap the element
             nonzero = nonzero[0]
         return np.asanyarray(nonzero)
-    elif np.issubdtype(index_array.dtype, int):
+    elif np.issubdtype(index_array.dtype, np.integer):
         return index_array
     elif np.issubdtype(index_array.dtype, float):
         int_index = index_array.astype(np.intp)


Test patch:
diff --git a/dask/array/tests/test_array_core.py b/dask/array/tests/test_array_core.py
index d6af863f3..f6f04ee7a 100644
--- a/dask/array/tests/test_array_core.py
+++ b/dask/array/tests/test_array_core.py
@@ -1611,6 +1611,14 @@ def test_slice_with_floats():
         d[[1, 1.5]]
 
 
+def test_slice_with_uint():
+    x = np.arange(10)
+    dx = da.from_array(x, chunks=5)
+    inds = np.array([0, 3, 6], dtype='u8')
+    assert_eq(dx[inds], x[inds])
+    assert_eq(dx[inds.astype('u4')], x[inds.astype('u4')])
+
+
 def test_vindex_basic():
     x = np.arange(56).reshape((7, 8))
     d = da.from_array(x, chunks=(3, 4))