Repository: pydata/sparse

Issue:
empty lists not allowed by advanced indexing
Empty lists are accepted by numpy in advanced indexing. But if used in COO.__getitem__ they get caught by sparse.slicing.normalize_index(). 
It seems pedantic, but as I try to replace some dense arrays in my code with sparse arrays, I have to fix this. This needs additional code and makes the code more complex. 
```
from sparse.slicing import normalize_index
from numpy import array
index = ([], )
a = array([])
a[index]
Output: array([], dtype=float64)

normalize_index(index, (0,))
Output: IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
```

Discussion:

Patch:
diff --git a/sparse/_slicing.py b/sparse/_slicing.py
index e445a4b..76f0993 100644
--- a/sparse/_slicing.py
+++ b/sparse/_slicing.py
@@ -156,15 +156,17 @@ def sanitize_index(ind):
                      _sanitize_index_element(ind.step))
     elif isinstance(ind, Number):
         return _sanitize_index_element(ind)
-    index_array = np.asanyarray(ind)
-    if index_array.dtype == np.bool_:
-        nonzero = np.nonzero(index_array)
+    if not hasattr(ind, 'dtype') and len(ind) == 0:
+        ind = np.array([], dtype=np.intp)
+    ind = np.asarray(ind)
+    if ind.dtype == np.bool_:
+        nonzero = np.nonzero(ind)
         if len(nonzero) == 1:
             # If a 1-element tuple, unwrap the element
             nonzero = nonzero[0]
         return np.asanyarray(nonzero)
-    elif np.issubdtype(index_array.dtype, np.integer):
-        return index_array
+    elif np.issubdtype(ind.dtype, np.integer):
+        return ind
     else:
         raise IndexError("only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and "
                          "integer or boolean arrays are valid indices")


Test patch:
diff --git a/sparse/tests/test_coo.py b/sparse/tests/test_coo.py
index 983625f..8aeea84 100644
--- a/sparse/tests/test_coo.py
+++ b/sparse/tests/test_coo.py
@@ -1275,6 +1275,7 @@ def test_slicing(index):
     (1, [0, 2]),
     (0, [1, 0], 0),
     (1, [2, 0], 0),
+    (1, [], 0),
     ([True, False], slice(1, None), slice(-2, None)),
     (slice(1, None), slice(-2, None), [True, False, True, False]),
     ([1, 0],),