You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to index a Dataset using an index array of dtype uint64 yields a ValueError. int64 works fine. See below:
In [13]: import xarray
In [14]: ds = xarray.Dataset({"A": (("x", "y"), arange(5*6).reshape(5,6))})
In [15]: ds[{"x": numpy.array([0], dtype="int64")}]
Out[15]:
<xarray.Dataset>
Dimensions: (x: 1, y: 6)
Dimensions without coordinates: x, y
Data variables:
A (x, y) int64 0 1 2 3 4 5
In [16]: ds[{"x": numpy.array([0], dtype="uint64")}]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-16-4cf23af0967e> in <module>()
----> 1 ds[{"x": numpy.array([0], dtype="uint64")}]
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/dataset.py in __getitem__(self, key)
722 """
723 if utils.is_dict_like(key):
--> 724 return self.isel(**key)
725
726 if hashable(key):
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/dataset.py in isel(self, drop, **indexers)
1147 for name, var in iteritems(self._variables):
1148 var_indexers = dict((k, v) for k, v in indexers if k in var.dims)
-> 1149 new_var = var.isel(**var_indexers)
1150 if not (drop and name in var_indexers):
1151 variables[name] = new_var
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/variable.py in isel(self, **indexers)
547 if dim in indexers:
548 key[i] = indexers[dim]
--> 549 return self[tuple(key)]
550
551 def squeeze(self, dim=None):
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/variable.py in __getitem__(self, key)
377 dims = tuple(dim for k, dim in zip(key, self.dims)
378 if not isinstance(k, integer_types))
--> 379 values = self._indexable_data[key]
380 # orthogonal indexing should ensure the dimensionality is consistent
381 if hasattr(values, 'ndim'):
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/indexing.py in __getitem__(self, key)
467
468 def __getitem__(self, key):
--> 469 key = self._convert_key(key)
470 return self._ensure_ndarray(self.array[key])
471
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/indexing.py in _convert_key(self, key)
454 if any(not isinstance(k, integer_types + (slice,)) for k in key):
455 # key would trigger fancy indexing
--> 456 key = orthogonal_indexer(key, self.shape)
457 return key
458
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/indexing.py in orthogonal_indexer(key, shape)
78 """
79 # replace Ellipsis objects with slices
---> 80 key = list(canonicalize_indexer(key, len(shape)))
81 # replace 1d arrays and slices with broadcast compatible arrays
82 # note: we treat integers separately (instead of turning them into 1d
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/indexing.py in canonicalize_indexer(key, ndim)
66 return indexer
67
---> 68 return tuple(canonicalize(k) for k in expanded_indexer(key, ndim))
69
70
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/indexing.py in <genexpr>(.0)
66 return indexer
67
---> 68 return tuple(canonicalize(k) for k in expanded_indexer(key, ndim))
69
70
/dev/shm/gerrit/venv/stable-3.5/lib/python3.5/site-packages/xarray/core/indexing.py in canonicalize(indexer)
63 'array indexing; all subkeys must be '
64 'slices, integers or sequences of '
---> 65 'integers or Booleans' % indexer)
66 return indexer
67
ValueError: invalid subkey array([0], dtype=uint64) for integer based array indexing; all subkeys must be slices, integers or sequences of integers or Booleans
The text was updated successfully, but these errors were encountered:
Trying to index a
Dataset
using an index array of dtypeuint64
yields aValueError
.int64
works fine. See below:The text was updated successfully, but these errors were encountered: