Skip to content
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
16 changes: 16 additions & 0 deletions src/uproot/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's tests aren't expected to enter here

classname = cursor.string(chunk, context)
cursor.skip(1)
cls = file.class_named(classname)
Expand Down Expand Up @@ -424,6 +426,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's 00,03,25,27,30,33,35,36,38,39,45,47,51,56,57,58,60,61,63,65,68,70,71,72,73,74,75,78,79

helper_obj = uproot._awkward_forth.GenHelper(context)

if helper_obj.is_forth():
Expand Down Expand Up @@ -569,6 +573,8 @@ def awkward_form(self, file, context):
raise uproot.interpretation.objects.CannotBeAwkward("arbitrary pointer")

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's 29,45,46,49,50 (Awkward Form discovered at read-time)

return uproot.deserialization.read_object_any(
chunk, cursor, context, file, selffile, parent
)
Expand Down Expand Up @@ -666,6 +672,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's 01,02,23,24,25,26,27,28,30,51,52

helper_obj = uproot._awkward_forth.GenHelper(context)

if helper_obj.is_forth():
Expand Down Expand Up @@ -835,6 +843,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's (none! untested! but it's just like AsVector)

if self._header and header:
start_cursor = cursor.copy()
(
Expand Down Expand Up @@ -981,6 +991,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's 00,03,04,06,07,08,09,10,11,12,13,14,15,16,17,23,24,26,27,28,31,33,36,38,41,42,43,44,45,46,49,50,55,56,57,58,59,60,61,62,63,67,68,72,73,76,77,80

helper_obj = uproot._awkward_forth.GenHelper(context)

if helper_obj.is_forth():
Expand Down Expand Up @@ -1188,6 +1200,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's 62,63,64,65,69,70,74,75,77

if self._header and header:
start_cursor = cursor.copy()
(
Expand Down Expand Up @@ -1342,6 +1356,8 @@ def awkward_form(self, file, context):
)

def read(self, chunk, cursor, context, file, selffile, parent, header=True):
# @aryan26roy: test_0637's 00,33,35,39,47,48,66,67,68,69,70,71,72,73,74,75,76,77,78,79

if self._header and header:
start_cursor = cursor.copy()
(
Expand Down
6 changes: 5 additions & 1 deletion src/uproot/interpretation/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ def final_array(

start = stop

if all(uproot._util.from_module(x, "awkward") for x in basket_arrays.values()):
if len(basket_arrays) == 0:
output = numpy.array([], dtype=self.numpy_dtype)
elif all(
uproot._util.from_module(x, "awkward") for x in basket_arrays.values()
):
Comment on lines -358 to +362
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an actual bug-fix, discovered while arranging these tests but otherwise unrelated to them.

assert isinstance(library, uproot.interpretation.library.Awkward)
awkward = library.imported
output = awkward.concatenate(trimmed, mergebool=False, highlevel=False)
Expand Down
2 changes: 2 additions & 0 deletions src/uproot/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ def read(cls, chunk, cursor, context, file, selffile, parent, concrete=None):
)

if context.get("in_TBranch", False):
# @aryan26roy: test_0637's 01,02,05,08,09,11,12,13,15,16,29,35,38,39,44,45,46,47,49,50,52,56

if self._num_bytes is None and self._instance_version != self.class_version:
self._instance_version = None
cursor = self._cursor
Expand Down
21 changes: 21 additions & 0 deletions src/uproot/streamers.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,9 @@ def class_code(
key = forth_obj.get_key()\n"""
)
read_member_n.append(f" if member_index == {i}:")

# @aryan26roy: test_0637's 01,02,08,09,11,12,13,15,16,29,38,45,46,49,50

read_members.append(
f" self._bases.append(c({self.name!r}, {self.base_version!r}).read(chunk, cursor, context, file, self._file, self._parent, concrete=self.concrete))"
)
Expand Down Expand Up @@ -801,6 +804,8 @@ def class_code(
)
read_member_n.append(" " + read_members[-1].replace("\n", "\n "))

# @aryan26roy: test_0637's 29,44,56

read_members.append(
f" self._members[{self.name!r}] = cursor.array(chunk, self.member({self.count_name!r}), tmp, context)"
)
Expand Down Expand Up @@ -907,13 +912,19 @@ def class_code(
or elements[i + 1].array_length != 0
):
if len(fields[-1]) == 1:
# @aryan26roy: test_0637's 01,02,29,38,44,56

read_members.append(
f" self._members[{fields[-1][0]!r}] = cursor.field(chunk, self._format{len(formats) - 1}, context)"
)

else:
assign_members = ", ".join(
f"self._members[{x!r}]" for x in fields[-1]
)

# @aryan26roy: test_0637's 01,02,05,08,09,11,12,13,15,16,29,35,39,45,46,47,49,50,56

read_members.append(
f" {assign_members} = cursor.fields(chunk, self._format{len(formats) - 1}, context)"
)
Expand All @@ -923,6 +934,8 @@ def class_code(
)

else:
# @aryan26roy: test_0637's 44,56

read_members.append(
f" self._members[{self.name!r}] = cursor.array(chunk, {self.array_length}, self._dtype{len(dtypes)}, context)"
)
Expand Down Expand Up @@ -1185,6 +1198,8 @@ def class_code(
string_header=True,
)

# @aryan26roy: test_0637's 35,38,39,44,45,47,50,56

read_members.append(
f" self._members[{self.name!r}] = self._stl_container{len(containers)}.read(chunk, cursor, context, file, self._file, self.concrete)"
)
Expand Down Expand Up @@ -1291,6 +1306,8 @@ def class_code(
read_member_n.append(f" if member_index == {i}:")

if self.fType == uproot.const.kObjectp or self.fType == uproot.const.kAnyp:
# @aryan26roy: test_0637's (none! untested!)

read_members.append(
f" self._members[{self.name!r}] = c({self.typename.rstrip('*')!r}).read(chunk, cursor, context, file, self._file, self.concrete)"
)
Expand All @@ -1304,6 +1321,8 @@ def class_code(
)

elif self.fType == uproot.const.kObjectP or self.fType == uproot.const.kAnyP:
# @aryan26roy: test_0637's (none! untested!)

read_members.append(
f" self._members[{self.name!r}] = read_object_any(chunk, cursor, context, file, self._file, self)"
)
Expand Down Expand Up @@ -1412,6 +1431,8 @@ def class_code(
):
read_member_n.append(f" if member_index == {i}:")

# @aryan26roy: test_0637's 01,02,29,45,46,49,50,56

read_members.append(
f" self._members[{self.name!r}] = c({self.typename.rstrip('*')!r}).read(chunk, cursor, context, file, self._file, self.concrete)"
)
Expand Down
25 changes: 25 additions & 0 deletions tests/test_0031-test-stl-containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@
from uproot.interpretation.objects import AsObjects


@pytest.mark.skip(
reason="Implement non-memberwise std::map; we have a sample (map<string,double>)"
)
def test_nonmemberwise_asmap():
Comment on lines +17 to +20
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for me to implement non-memberwise std::map in Python, so that you can develop Forth code for both the memberwise and non-memberwise cases. (Just for std::map.) These four tests will be added to test_0637.

with uproot.open(skhep_testdata.data_path("uproot-issue243.root")) as file:
branch = file["triggerList/triggerMap"]
interp = uproot.interpretation.identify.interpretation_of(branch, {}, False)
py = branch.array(library="np", entry_stop=2)

with uproot.open(skhep_testdata.data_path("uproot-issue-268.root")) as file:
branch = file["aTree/VtxTracks/channels_"]
interp = uproot.interpretation.identify.interpretation_of(branch, {}, False)
py = branch.array(library="np", entry_stop=2)

with uproot.open(skhep_testdata.data_path("uproot-issue-268.root")) as file:
branch = file["aTree/VtxTracks2TofHits/match_"]
interp = uproot.interpretation.identify.interpretation_of(branch, {}, False)
py = branch.array(library="np", entry_stop=2)

with uproot.open(skhep_testdata.data_path("uproot-issue-268.root")) as file:
branch = file["aTree/VtxTracks2TofHits/match_inverted_"]
interp = uproot.interpretation.identify.interpretation_of(branch, {}, False)
py = branch.array(library="np", entry_stop=2)


def test_typename():
with uproot.open(skhep_testdata.data_path("uproot-stl_containers.root"))[
"tree"
Expand Down
Loading