Skip to content

Commit 62aaa7d

Browse files
committed
Reverted granularity of page ranges
1 parent ee55293 commit 62aaa7d

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

src/uproot/behaviors/RNTuple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ def arrays(
754754

755755
for key in target_cols:
756756
if "column" in key and "union" not in key:
757-
# TODO: Need some logic to find the start and stop pages
758757
key_nr = int(key.split("-")[1])
759758
# Find how many elements should be padded at the beginning
760759
n_padding = self.ntuple.column_records[key_nr].first_element_index
@@ -763,7 +762,8 @@ def arrays(
763762
if interpreter == "cpu":
764763
content = self.ntuple.read_cluster_range(
765764
key_nr,
766-
range(start_cluster_idx, stop_cluster_idx),
765+
start_cluster_idx,
766+
stop_cluster_idx,
767767
missing_element_padding=n_padding,
768768
array_cache=array_cache,
769769
)

src/uproot/models/RNTuple.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -662,53 +662,42 @@ def read_page(
662662
def read_cluster_range(
663663
self,
664664
col_idx,
665-
cluster_range,
665+
cluster_start,
666+
cluster_stop,
666667
missing_element_padding=0,
667-
first_cluster_page_start=None,
668-
last_cluster_page_stop=None,
669668
array_cache=None,
670669
):
671670
"""
672671
Args:
673-
ncol (int): The column id.
674-
cluster_range (range): The range of cluster indices.
672+
col_idx (int): The column index.
673+
cluster_start (int): The first cluster to include.
674+
cluster_stop (int): The first cluster to exclude (i.e. one greater than the last cluster to include).
675675
missing_element_padding (int): Number of padding elements to add at the start of the array.
676-
first_cluster_page_start (None or int): The first page of the first cluster to include. If None, start from the beginning.
677-
If negative, count from the end, like a Python slice.
678-
last_cluster_page_stop (None or int): The first page of the last cluster to exclude (i.e. one greater
679-
than the last page to include). If None, stop at the end. If negative,
680-
count from the end, like a Python slice.
681676
array_cache (None, or MutableMapping): Cache of arrays. If None, do not use a cache.
682677
683678
Returns a numpy array with the data from the column.
684679
"""
685680
field_metadata = self.get_field_metadata(col_idx)
686681
arrays = [
687-
self.read_page_range(
682+
self.read_pages(
688683
cluster_idx,
689684
col_idx,
690685
field_metadata,
691-
page_start=first_cluster_page_start if i == 0 else None,
692-
page_stop=(
693-
last_cluster_page_stop if i == len(cluster_range) - 1 else None
694-
),
695686
array_cache=array_cache,
696687
)
697-
for i, cluster_idx in enumerate(cluster_range)
688+
for cluster_idx in range(cluster_start, cluster_stop)
698689
]
699690
res = self.combine_cluster_arrays(
700691
arrays, field_metadata, missing_element_padding
701692
)
702693

703694
return res
704695

705-
def read_page_range(
696+
def read_pages(
706697
self,
707698
cluster_idx,
708699
col_idx,
709700
field_metadata,
710-
page_start=None,
711-
page_stop=None,
712701
array_cache=None,
713702
):
714703
"""
@@ -717,9 +706,6 @@ def read_page_range(
717706
col_idx (int): The column index.
718707
field_metadata (:doc:`uproot.models.RNTuple.FieldClusterMetadata`):
719708
The metadata needed to read the field's pages.
720-
page_start (None or int): The first page to include. If None, start from the beginning.
721-
page_stop (None or int): The first page to exclude (i.e. one greater
722-
than the last page to include). If None, stop at the end.
723709
array_cache (None or MutableMapping): Cache of arrays. If None, do not use a cache.
724710
725711
Returns a numpy array with the data from the column.
@@ -733,7 +719,7 @@ def read_page_range(
733719
col_idx
734720
) # Update metadata if suppressed
735721
pagelist = (
736-
linklist[field_metadata.ncol].pages[page_start:page_stop]
722+
linklist[field_metadata.ncol].pages
737723
if field_metadata.ncol < len(linklist)
738724
else []
739725
)
@@ -742,9 +728,7 @@ def read_page_range(
742728

743729
tracker = 0
744730
cumsum = 0
745-
for page_idx, page_desc in enumerate(
746-
pagelist, start=page_start if page_start is not None else 0
747-
):
731+
for page_idx, page_desc in enumerate(pagelist):
748732
n_elements = page_desc.num_elements
749733
tracker_end = tracker + n_elements
750734
self.read_page(

tests/test_1191_rntuple_fixes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_multiple_page_delta_encoding():
5959
with uproot.open(filename) as f:
6060
obj = f["ntuple"]
6161
field_metadata = obj.get_field_metadata(0)
62-
data = obj.read_page_range(0, 0, field_metadata)
62+
data = obj.read_pages(0, 0, field_metadata)
6363
# first page has 64 elements, so this checks that data was stitched together correctly
6464
assert data[64] - data[63] == 2
6565

0 commit comments

Comments
 (0)