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

Commit

Permalink
fix 0-leaf dtypes, branch printout formatting, and STLstreamers with …
Browse files Browse the repository at this point in the history
…a 'This' member
  • Loading branch information
jpivarski committed Nov 27, 2017
1 parent 62f3f4c commit b577c9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion uproot/interp/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def interpret(branch, classes=None, swapbytes=True):
else:
return asjagged(out)

else:
elif len(branch.fLeaves) > 1:
fromdtype = numpy.dtype([(leaf.fName.decode("ascii"), _leaf2dtype(leaf).newbyteorder(">")) for leaf in branch.fLeaves])
if swapbytes:
todtype = numpy.dtype([(leaf.fName.decode("ascii"), _leaf2dtype(leaf).newbyteorder("=")) for leaf in branch.fLeaves])
Expand Down
23 changes: 13 additions & 10 deletions uproot/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ def _attachstreamer(self, branch, streamer, streamerinfosmap):
# FIXME: can only determine streamer by reading some values?
return

elif len(streamer.fElements) == 1 and isinstance(streamer.fElements[0], uproot.rootio.TStreamerSTL) and streamer.fElements[0].fName == b"This":
return self._attachstreamer(branch, streamer.fElements[0], streamerinfosmap)

branch._streamer = streamer

digDeeperTypes = (uproot.rootio.TStreamerObject, uproot.rootio.TStreamerObjectAny, uproot.rootio.TStreamerObjectPointer, uproot.rootio.TStreamerObjectAnyPointer)
Expand Down Expand Up @@ -379,8 +382,8 @@ def _format(self, indent=""):
out.extend(branch._format(indent))
return out

def format(self):
return "\n".join(self._format())
def format(self, foldnames=False):
return "\n".join(self._format(foldnames))

def _normalize_branches(self, arg):
if arg is None: # no specification; read all branches
Expand Down Expand Up @@ -1223,25 +1226,25 @@ def _basketkey(self, source, i, complete):
raise IndexError("index {0} out of range for branch with {1} baskets".format(i, self.numbaskets))
return self._BasketKey(source.parent(), Cursor(self.fBasketSeek[i]), uproot.source.compressed.Compression(self.fCompress), complete)

def _format(self, indent="", strip=""):
def _format(self, foldnames, indent="", strip=""):
name = self.fName.decode("ascii")
if name.startswith(strip + "."):
if foldnames and name.startswith(strip + "."):
name = name[len(strip) + 1:]

if len(name) > 40:
out = [indent + name, indent + "{0:40s} {1:20s} {2}".format("", self._streamer.__class__.__name__, interpret(self))]
if len(name) > 26:
out = [indent + name, indent + "{0:26s} {1:26s} {2}".format("", self._streamer.__class__.__name__, interpret(self))]
else:
out = [indent + "{0:40s} {1:20s} {2}".format(name, self._streamer.__class__.__name__, interpret(self))]
out = [indent + "{0:26s} {1:26s} {2}".format(name, self._streamer.__class__.__name__, interpret(self))]

for branch in self.fBranches:
out.extend(branch._format(" ", self.fName))
out.extend(branch._format(foldnames, indent + " " if foldnames else indent, self.fName))
if len(self.fBranches) > 0 and out[-1] != "":
out.append("")

return out

def format(self):
return "\n".join(self._format())
def format(self, foldnames=False):
return "\n".join(self._format(foldnames))

def __len__(self):
return self.numentries
Expand Down
2 changes: 1 addition & 1 deletion uproot/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import re

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

Expand Down

0 comments on commit b577c9d

Please sign in to comment.