Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #330 from scikit-hep/issue-329
Browse files Browse the repository at this point in the history
Fixes #329 by adding TRefArray.
  • Loading branch information
jpivarski committed Sep 5, 2019
2 parents df8467f + b033536 commit 3fb8293
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions uproot/rootio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,28 @@ def _recarray(cls):
TRef._arraymethods = None
TRef._fromrow = lambda row: TRef(row["id"])

class TRefArray(list, ROOTStreamedObject):
_format1 = struct.Struct(">i")
_dtype = numpy.dtype(">i4")

@classmethod
def _readinto(cls, self, source, cursor, context, parent):
start, cnt, self._classversion = _startcheck(source, cursor)
cursor.skip(10)
self.name = cursor.string(source)
self.length = cursor.field(source, self._format1)
cursor.skip(6)
self.extend(cursor.array(source, self.length, self._dtype))
_endcheck(start, cursor, cnt)
return self

@property
def nbytes(self):
return len(self) * self._dtype.itemsize

def tostring(self):
return numpy.asarray(self, dtype=self._dtype).tostring()

class TArray(list, ROOTStreamedObject):
@classmethod
def _readinto(cls, self, source, cursor, context, parent):
Expand Down Expand Up @@ -1454,6 +1476,7 @@ def __repr__(self):
"TArrayL64": TArrayL64,
"TArrayF": TArrayF,
"TArrayD": TArrayD,
"TRefArray": TRefArray,
"ROOT_3a3a_TIOFeatures": ROOT_3a3a_TIOFeatures}

builtin_skip = {"TBranch": ["fBaskets"],
Expand Down
2 changes: 1 addition & 1 deletion uproot/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import re

__version__ = "3.9.2"
__version__ = "3.9.3"
version = __version__
version_info = tuple(re.split(r"[-\.]", __version__))

Expand Down

0 comments on commit 3fb8293

Please sign in to comment.