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

Completed the Forth based AsStrings reader. #616

Merged
merged 4 commits into from
Jun 21, 2022
Merged
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
30 changes: 30 additions & 0 deletions src/uproot/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,36 @@ def memory_size(data, error_message=None):
raise TypeError(error_message)


def trim_final(basket_arrays, entry_start, entry_stop, entry_offsets, library, branch):
"""
Trims the output from a basket_array function and outputs the un-concatenated list of elements.
"""
trimmed = []
start = entry_offsets[0]
for basket_num, stop in enumerate(entry_offsets[1:]):
if start <= entry_start and entry_stop <= stop:
local_start = entry_start - start
local_stop = entry_stop - start
trimmed.append(basket_arrays[basket_num][local_start:local_stop])

elif start <= entry_start < stop:
local_start = entry_start - start
local_stop = stop - start
trimmed.append(basket_arrays[basket_num][local_start:local_stop])

elif start <= entry_stop <= stop:
local_start = 0
local_stop = entry_stop - start
trimmed.append(basket_arrays[basket_num][local_start:local_stop])

elif entry_start < stop and start <= entry_stop:
trimmed.append(basket_arrays[basket_num])

start = stop

return trimmed


def new_class(name, bases, members):
"""
Create a new class object with ``type(name, bases, members)`` and put it in
Expand Down
Loading