Skip to content

Commit 9e092ee

Browse files
committed
fix for reading just first row of vov, changed so if idx is ordered array of integers starting at 0 we just ignore
1 parent bbc6db7 commit 9e092ee

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/lgdo/lh5/store.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,15 @@ def read(
417417

418418
# Below here is all array-like types. So trim idx if needed
419419
if idx is not None:
420-
# chop off indices < start_row
421-
i_first_valid = bisect_left(idx[0], start_row)
422-
idxa = idx[0][i_first_valid:]
423-
# don't readout more than n_rows indices
424-
idx = (idxa[:n_rows],) # works even if n_rows > len(idxa)
420+
# check if idx is just an ordered list of the integers if so can ignore
421+
if (idx[0] == np.arange(0,len(idx[0]),1)).all():
422+
idx = None
423+
else:
424+
# chop off indices < start_row
425+
i_first_valid = bisect_left(idx[0], start_row)
426+
idxa = idx[0][i_first_valid:]
427+
# don't readout more than n_rows indices
428+
idx = (idxa[:n_rows],) # works even if n_rows > len(idxa)
425429

426430
# Table or WaveformTable
427431
if datatype == "table":

tests/lh5/test_lh5_store.py

+4
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ def test_read_vov(lh5_file):
245245

246246
def test_read_vov_fancy_idx(lh5_file):
247247
store = lh5.LH5Store()
248+
249+
lh5_obj, n_rows = store.read("/data/struct_full/vov", lh5_file, idx=[0], n_rows=1)
250+
assert isinstance(lh5_obj, types.VectorOfVectors)
251+
248252
lh5_obj, n_rows = store.read("/data/struct_full/vov", lh5_file, idx=[0, 2])
249253
assert isinstance(lh5_obj, types.VectorOfVectors)
250254

0 commit comments

Comments
 (0)