Skip to content

Commit

Permalink
Fixed bugs with read multiple files with indices
Browse files Browse the repository at this point in the history
  • Loading branch information
iguinn committed Sep 3, 2024
1 parent c835b7c commit 968ea92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lgdo/lh5/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ def read(
if not (isinstance(idx, tuple) and len(idx) == 1):
idx = (idx,)
# idx is a long continuous array
n_rows_i = read_n_rows(h5f)
n_rows_i = read_n_rows(name, h5f)
# find the length of the subset of idx that contains indices
# that are less than n_rows_i
n_rows_to_read_i = bisect.bisect_left(idx[0], n_rows_i)
# now split idx into idx_i and the remainder
idx_i = idx[0][:n_rows_to_read_i]
idx = idx[0][n_rows_to_read_i:] - n_rows_i
idx_i = np.array(idx[0])[:n_rows_to_read_i]
idx = np.array(idx[0])[n_rows_to_read_i:] - n_rows_i
else:
idx_i = None
n_rows_i = n_rows - n_rows_read
Expand Down
6 changes: 3 additions & 3 deletions src/lgdo/lh5/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ def read(
if not (isinstance(idx, tuple) and len(idx) == 1):
idx = (idx,)
# idx is a long continuous array
n_rows_i = utils.read_n_rows(h5f)
n_rows_i = utils.read_n_rows(name, h5f)
# find the length of the subset of idx that contains indices
# that are less than n_rows_i
n_rows_to_read_i = bisect.bisect_left(idx[0], n_rows_i)
# now split idx into idx_i and the remainder
idx_i = idx[0][:n_rows_to_read_i]
idx = idx[0][n_rows_to_read_i:] - n_rows_i
idx_i = np.array(idx[0])[:n_rows_to_read_i]
idx = np.array(idx[0])[n_rows_to_read_i:] - n_rows_i
else:
idx_i = None
n_rows_i = n_rows - n_rows_read
Expand Down

0 comments on commit 968ea92

Please sign in to comment.