Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use fast uproot.num_entries method instead of TTree.num_entries #1197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ dask-worker-space/

# VCS versioning
src/coffea/_version.py

# pyright LSP
pyrightconfig.json
2 changes: 1 addition & 1 deletion src/coffea/dataset_tools/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_steps(
else:
raise e

num_entries = tree.num_entries
num_entries = next(uproot.num_entries(f"{arg.file}:{arg.object_path}"))[-1]

form_json = None
form_hash = None
Expand Down
6 changes: 4 additions & 2 deletions src/coffea/nanoevents/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,10 @@ def from_root(

if entry_start is None or entry_start < 0:
entry_start = 0
if entry_stop is None or entry_stop > tree.num_entries:
entry_stop = tree.num_entries
# should use uproot.num_entries instead...
nentries = tree.num_entries
if entry_stop is None or entry_stop > nentries:
entry_stop = nentries

partition_key = (
str(tree.file.uuid),
Expand Down
Loading