How to use the uproot.rootio._bytesid function in uproot

To help you get started, we’ve selected a few uproot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FAST-HEP / fast-carpenter / fast_carpenter / tree_wrapper.py View on Github external
def new_variable(self, name, value):
        if name in self:
            msg = "Trying to overwrite existing variable: '%s'"
            raise ValueError(msg % name)
        if len(value) != len(self):
            msg = "New array %s does not have the right length: %d not %d"
            raise ValueError(msg % (name, len(value), len(self)))

        outputtype = WrappedTree.FakeBranch

        name = uproot.rootio._bytesid(name)
        self.extras[name] = outputtype(name, value, self.event_ranger)
github scikit-hep / uproot / uproot / write / objects / TTree.py View on Github external
def __init__(self, name, branchobj, compression, file):
        self.name = _bytesid(name)
        self.type = numpy.dtype(branchobj.type).newbyteorder(">")
        self.compression = compression
        self.util = None
        self.keycursor = None
        self.file = file

        self.fields = {"_fCompress": 100,
                       "_fBasketSize": 32000,
                       "_fEntryOffsetLen": 0,
                       "_fWriteBasket": 0,  # Number of baskets
                       "_fOffset": 0,
                       "_fMaxBaskets": 50,
                       "_fSplitLevel": 0,
                       "_fEntries": 0,
                       "_fFirstEntry": 0,
                       "_fTotBytes": 0,
github scikit-hep / uproot / uproot / write / objects / TH.py View on Github external
def __init__(self, histogram):
        self._fTitle = _bytesid(histogram._fTitle)
        self._fClassName = _bytesid(histogram._classname)

        self._fXaxis = self._emptyaxis("xaxis", 1.0)
        self._fXaxis.update(histogram._fXaxis.__dict__)
        self._fixaxis(self._fXaxis)

        self._fYaxis = self._emptyaxis("yaxis", 0.0)
        if hasattr(histogram, "_fYaxis"):
            self._fYaxis.update(histogram._fYaxis.__dict__)
        self._fixaxis(self._fYaxis)

        self._fZaxis = self._emptyaxis("zaxis", 1.0)
        if hasattr(histogram, "_fZaxis"):
            self._fZaxis.update(histogram._fZaxis.__dict__)
        self._fixaxis(self._fZaxis)
github scikit-hep / uproot / uproot / tree.py View on Github external
def _filename_explode(x):
    if isinstance(x, getattr(os, "PathLike", ())):
        x = os.fspath(x)
    elif hasattr(x, "__fspath__"):
        x = x.__fspath__()
    elif x.__class__.__module__ == "pathlib":
        import pathlib
        if isinstance(x, pathlib.Path):
             x = str(x)
    parsed = urlparse(x)
    if _bytesid(parsed.scheme) == b"file" or len(parsed.scheme) == 0 or (os.name == "nt" and _filename_explode._windows_absolute.match(x) is not None):
        if not (os.name == "nt" and _filename_explode._windows_absolute.match(x) is not None):
            path = parsed.netloc + parsed.path
        pattern = os.path.expanduser(path)
        if "*" in pattern or "?" in pattern or "[" in pattern:
            out = sorted(glob.glob(pattern))
            if len(out) == 0:
                raise TypeError("no matches for filename {0}".format(repr(pattern)))
        else:
            out = [pattern]
        return out
    else:
        return [x]
github scikit-hep / uproot / uproot / tree.py View on Github external
def get(self, name, recursive=True, filtername=nofilter, filtertitle=nofilter, aliases=True):
        name = _bytesid(name)
        for n, b in self.iteritems(recursive=recursive, filtername=filtername, filtertitle=filtertitle):
            if n == name:
                return b
        raise uproot.rootio._KeyError("not found: {0}\n in file: {1}".format(repr(name), self._context.sourcepath))
github scikit-hep / uproot / uproot / write / objects / TTree.py View on Github external
def __init__(self, name, newtree, file):
        self.name = name
        self.fClassName = b"TTree"
        self.fName = _bytesid(self.name)
        self.fTitle = _bytesid(newtree.title)
        self.file = file

        self.fields = {"_fLineColor": 602,
                       "_fLineStyle": 1,
                       "_fLineWidth": 1,
                       "_fFillColor": 0,
                       "_fFillStyle": 1001,
                       "_fMarkerColor": 1,
                       "_fMarkerStyle": 1,
                       "_fMarkerSize": 1.0,
                       "_fEntries": 0,
                       "_fTotBytes": 0,
                       "_fZipBytes": 0,
                       "_fSavedBytes": 0,
                       "_fFlushedBytes": 0,
github scikit-hep / uproot / uproot / tree.py View on Github external
def get(self, name, recursive=True, filtername=nofilter, filtertitle=nofilter, aliases=True):
        name = _bytesid(name)
        try:
            return self._branchlookup[name]
        except KeyError:
            for n, b in self.iteritems(recursive=recursive, filtername=filtername, filtertitle=filtertitle, aliases=aliases):
                if n == name:
                    self._branchlookup[name] = b
                    return b
            raise uproot.rootio._KeyError("not found: {0}\n in file: {1}".format(repr(name), self._context.sourcepath))