Skip to content

Commit

Permalink
stash changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Apr 10, 2024
1 parent 683bf37 commit 398ab2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections import OrderedDict
from typing import NamedTuple, Union
from warnings import warn
# import h5py

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -1621,6 +1622,13 @@ def _get_helper(self, idx, index=False, join=False, **kwargs):
return idx
if not np.isscalar(idx):
idx = np.asarray(idx)
# if isinstance(self.elements.data, h5py.Dataset):
# # h5py datasets cannot index with an array of indices that are not in increasing order
# # so unpack them one by one
# ret = np.empty(idx.shape, dtype=self.elements.data.dtype)
# for i, j in enumerate(idx.ravel()):
# ret[i] = self.elements.get(j, **kwargs)
# else:
ret = np.asarray(self.elements.get(idx.ravel(), **kwargs)).reshape(idx.shape)
if join:
ret = ''.join(ret.ravel())
Expand Down
3 changes: 3 additions & 0 deletions src/hdmf/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,10 @@ def __getitem__(self, args):

def get(self, args):
if isinstance(self.data, (tuple, list)) and isinstance(args, (tuple, list, np.ndarray)):
# try:
return [self.data[i] for i in args]
# except:
# breakpoint()
if isinstance(self.data, h5py.Dataset) and isinstance(args, np.ndarray):
# This is needed for h5py 2.9 compatibility
args = args.tolist()
Expand Down

0 comments on commit 398ab2d

Please sign in to comment.