diff --git a/uproot/rootio.py b/uproot/rootio.py index fc1a60ce..8c2a2aa2 100644 --- a/uproot/rootio.py +++ b/uproot/rootio.py @@ -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): @@ -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"], diff --git a/uproot/version.py b/uproot/version.py index cf0d9724..ef56691e 100644 --- a/uproot/version.py +++ b/uproot/version.py @@ -6,7 +6,7 @@ import re -__version__ = "3.9.2" +__version__ = "3.9.3" version = __version__ version_info = tuple(re.split(r"[-\.]", __version__))