Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return asgenobj(STLMap(STLString(awkward), STLString(awkward)), branch._context, 6)
if getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(awkward.numpy.bool_))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype("i1"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype("u1"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">i2"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">u2"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">i4"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">u4"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">i8"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">u8"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">f4"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">f8"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(STLString(awkward))), branch._context, 6)
m = re.match(b"bitset<([1-9][0-9]*)>", branch._fClassName)
if m is not None:
return asstlbitset(int(m.group(1)))
if branch._fClassName == b"string":
bytestarts = byteoffsets[local_entrystart : local_entrystop ] + self.skipbytes
bytestops = byteoffsets[local_entrystart + 1 : local_entrystop + 1]
mask = awkward.util.numpy.zeros(len(data), dtype=awkward.util.numpy.int8)
mask[bytestarts[bytestarts < len(data)]] = 1
awkward.util.numpy.add.at(mask, bytestops[bytestops < len(data)], -1)
awkward.util.numpy.cumsum(mask, out=mask)
data = data[mask.view(awkward.util.numpy.bool_)]
content = self.content.fromroot(data, None, 0, bytestops[-1])
itemsize = 1
sub = self.content
while hasattr(sub, "content"):
sub = sub.content
if isinstance(sub, uproot.interp.numerical.asdtype):
itemsize = sub.fromdtype.itemsize
counts = bytestops - bytestarts
shift = math.log(itemsize, 2)
if shift == round(shift):
awkward.util.numpy.right_shift(counts, int(shift), out=counts)
else:
awkward.util.numpy.floor_divide(counts, itemsize, out=counts)
offsets = awkward.util.numpy.empty(len(counts) + 1, awkward.util.INDEXTYPE)
offsets[0] = 0
awkward.util.numpy.cumsum(counts, out=offsets[1:])
return JaggedArray(offsets[:-1], offsets[1:], content)
if streamerClass._methods is None:
return asjagged(astable(asdtype(recarray)), skipbytes=10)
else:
return asjagged(asobj(astable(asdtype(recarray)), streamerClass._methods), skipbytes=10)
if hasattr(branch._streamer, "_fTypeName"):
m = re.match(b"bitset<([1-9][0-9]*)>", branch._streamer._fTypeName)
if m is not None:
return asjagged(asstlbitset(int(m.group(1))), skipbytes=6)
if getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype(awkward.numpy.bool_), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("i1"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("u1"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("i2"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("u2"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("i4"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("u4"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("i8"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("u8"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("f4"), skipbytes=10)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector" or getattr(branch._streamer, "_fTypeName", None) == b"vector":
return asjagged(asdtype("f8"), skipbytes=10)
Parameters
----------
array : ``numpy.ndarray``
the array to fill, instead of allocating a new one.
Returns
-------
:py:class:`asarray `
new interpretation.
"""
_method(uproot.interp.numerical.asdtype.empty).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.compatible).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.numitems).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.source_numitems).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.fromroot).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.destination).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.fill).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.clip).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.finalize).__doc__ = interp_fragments["see1"]
################################################################ uproot.interp.numerical.asarray
uproot.interp.numerical.asarray.__doc__ = \
u"""Interpret branch as array data that should overwrite an existing array.
This interpretation directs branch-reading functions to fill the given Numpy array with branch contents. See :py:class:`asdtype ` to allocate a new array, rather than filling an existing array.
{items}
Parameters
----------
def __init__(self, cls, context, skipbytes):
super(asgenobj, self).__init__(uproot.interp.jagged.asjagged(uproot.interp.numerical.asdtype(self.awkward.ObjectArray.CHARTYPE), skipbytes=skipbytes), asgenobj._Wrapper(cls, context))
def futures2df(futures, outputtype, entrystart, entrystop, flatten, flatname, awkward):
import pandas
if flatname is None:
flatname = default_flatname
if not flatten or all(interpretation.__class__ is not asjagged for name, interpretation, future in futures):
columns = []
data = {}
for name, interpretation, future in futures:
array = future()
if isinstance(interpretation, asobj) and isinstance(interpretation.content, astable):
interpretation = interpretation.content
if isinstance(interpretation, astable) and isinstance(interpretation.content, asdtype):
interpretation = interpretation.content
if isinstance(interpretation, asdtype):
if interpretation.todims == ():
if interpretation.todtype.names is None:
fn = flatname(name, None, ())
columns.append(fn)
data[fn] = array
else:
for nn in interpretation.todtype.names:
if not nn.startswith(" "):
fn = flatname(name, nn, ())
columns.append(fn)
data[fn] = array[nn]
else:
for tup in itertools.product(*[range(x) for x in interpretation.todims]):
return asgenobj(STLVector(STLVector(asdtype(">u8"))), branch._context, 6)
elif branch._fClassName == b"vector >" or branch._fClassName == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">f4"))), branch._context, 6)
elif branch._fClassName == b"vector >" or branch._fClassName == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">f8"))), branch._context, 6)
elif branch._fClassName == b"vector >":
return asgenobj(STLVector(STLVector(STLString(awkward))), branch._context, 6)
if branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype(awkward.numpy.bool_)), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("i1")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("u1")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("i2")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("u2")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("i4")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("u4")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("i8")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("u8")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("f4")), branch._context, 6)
elif branch._fClassName == b"map" or branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("f8")), branch._context, 6)
elif branch._fClassName == b"map":
return asgenobj(STLMap(STLString(awkward), STLString(awkward)), branch._context, 6)
return asgenobj(STLMap(STLString(awkward), asdtype("u8")), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"map" or getattr(branch._streamer, "_fTypeName", None) == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("f4")), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"map" or getattr(branch._streamer, "_fTypeName", None) == b"map":
return asgenobj(STLMap(STLString(awkward), asdtype("f8")), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"map":
return asgenobj(STLMap(STLString(awkward), STLString(awkward)), branch._context, 6)
if getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(awkward.numpy.bool_))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype("i1"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype("u1"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">i2"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">u2"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">i4"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">u4"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">i8"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">u8"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">f4"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >" or getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(asdtype(">f8"))), branch._context, 6)
elif getattr(branch._streamer, "_fTypeName", None) == b"vector >":
return asgenobj(STLVector(STLVector(STLString(awkward))), branch._context, 6)
Parameters
----------
todtype : ``None`` or ``numpy.dtype``
if not ``None``, change the destination type.
todims : ``None`` or tuple of ints
if not ``None``, change the destination dimensions.
Returns
-------
:py:class:`asdtype `
new interpretation.
"""
_method(uproot.interp.numerical.asdtype.toarray).__doc__ = \
u"""Create a :py:class:`asarray ` interpretation from this one.
Parameters
----------
array : ``numpy.ndarray``
the array to fill, instead of allocating a new one.
Returns
-------
:py:class:`asarray `
new interpretation.
"""
_method(uproot.interp.numerical.asdtype.empty).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.compatible).__doc__ = interp_fragments["see1"]
_method(uproot.interp.numerical.asdtype.numitems).__doc__ = interp_fragments["see1"]
def compatible(self, other):
return isinstance(other, asdtype) and self.todtype == other.todtype
def numitems(self, numbytes, numentries):
dtype, shape = _dtypeshape(self.fromdtype)
quotient, remainder = divmod(numbytes, dtype.itemsize)
assert remainder == 0
return quotient
def fromroot(self, data, byteoffsets, local_entrystart, local_entrystop, keylen):
dtype, shape = _dtypeshape(self.fromdtype)
return data.view(dtype).reshape((-1,) + shape)[local_entrystart:local_entrystop]
class asarray(asdtype):
# makes __doc__ attribute mutable before Python 3.3
__metaclass__ = type.__new__(type, "type", (asdtype.__metaclass__,), {})
def __init__(self, fromdtype, toarray):
if isinstance(fromdtype, self.awkward.numpy.dtype):
self.fromdtype = fromdtype
elif isinstance(fromdtype, string_types) and len(fromdtype) > 0 and fromdtype[0] in (">", "<", "=", "|", b">", b"<", b"=", b"|"):
self.fromdtype = self.awkward.numpy.dtype(fromdtype)
else:
self.fromdtype = self.awkward.numpy.dtype(fromdtype).newbyteorder(">")
self.toarray = toarray
@property
def todtype(self):
return self.awkward.numpy.dtype((self.toarray.dtype, self.toarray.shape[1:]))
def __repr__(self):
return "asarray({0}, )".format(repr(str(self.fromdtype)), self.toarray.dtype, self.toarray.shape, id(self.toarray))