diff --git a/src/hdmf/backends/hdf5/h5_utils.py b/src/hdmf/backends/hdf5/h5_utils.py index 0dc9733aa..7764ba39e 100644 --- a/src/hdmf/backends/hdf5/h5_utils.py +++ b/src/hdmf/backends/hdf5/h5_utils.py @@ -145,7 +145,7 @@ def dtype(self): def __getitem__(self, arg): rows = copy(super(AbstractH5TableDataset, self).__getitem__(arg)) - if isinstance(arg, int): + if np.issubdtype(type(arg), np.integer): self.__swap_refs(rows) else: for row in rows: diff --git a/src/hdmf/common/table.py b/src/hdmf/common/table.py index a43eb42b7..e6b687ede 100644 --- a/src/hdmf/common/table.py +++ b/src/hdmf/common/table.py @@ -443,11 +443,14 @@ def __getitem__(self, key): return self.__indices[arg] else: raise KeyError(arg) - elif isinstance(arg, (int, np.int8, np.int16, np.int32, np.int64)): + elif np.issubdtype(type(arg), np.integer): # index by int, return row ret = tuple(col[arg] for col in self.__df_cols) - elif isinstance(arg, (tuple, list)): + elif isinstance(arg, (tuple, list, np.ndarray)): # index by a list of ints, return multiple rows + if isinstance(arg, np.ndarray): + if len(arg.shape) != 1: + raise ValueError("cannot index DynamicTable with multiple dimensions") ret = list() for i in arg: ret.append(tuple(col[i] for col in self.__df_cols))