How to use the awkward.array.jagged.JaggedArray function in awkward

To help you get started, we’ve selected a few awkward 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 scikit-hep / awkward-array / awkward-numba / awkward / numba / array / jagged.py View on Github external
@numba.extending.typeof_impl.register(awkward.array.jagged.JaggedArray)
def _JaggedArray_typeof(val, c):
    return JaggedArrayType(numba.typeof(val.starts), numba.typeof(val.stops), numba.typeof(val.content), special=type(val))
github scikit-hep / awkward-array / awkward / derived / strings.py View on Github external
def copy(self, starts=None, stops=None, content=None, encoding=None):
        out = self.__class__.__new__(self.__class__)
        out._content = awkward.array.jagged.JaggedArray(self.starts, self.stops, self.content)
        out._generator = self._generator
        out._args = self._args
        out._kwargs = self._kwargs
        out._encoding = self._encoding
        if starts is not None:
            out.starts = starts
        if stops is not None:
            out.stops = stops
        if content is not None:
            out.content = content
        if encoding is not None:
            out.encoding = encoding
        return out
github scikit-hep / awkward-array / awkward / util.py View on Github external
def unwrap(a):
        if isinstance(a, awkward.array.chunked.ChunkedArray):
            chunks = [unwrap(x) for x in a.chunks]
            if any(isinstance(x, awkward.array.jagged.JaggedArray) for x in chunks):
                return awkward.array.jagged.JaggedArray.concatenate(chunks)
            else:
                return numpy.concatenate([x.regular() for x in chunks])
        elif isinstance(a, awkward.array.virtual.VirtualArray):
            return a.array
        else:
            return a
github scikit-hep / awkward-array / awkward / derived / strings.py View on Github external
def fromuniques(cls, uniques, content, encoding="utf-8"):
        out = cls.__new__(cls)
        out._content = awkward.array.jagged.JaggedArray.fromuniques(uniques, content)
        out._generator = tostring
        out._kwargs = {}
        out.encoding = encoding
        return out
github scikit-hep / awkward-array / awkward-numba / awkward / numba / array / jagged.py View on Github external
def fake2(array, where):
        out = _JaggedArray_getitem_next(awkward.array.jagged.JaggedArray(numpy.array([0], numpy.int64), numpy.array([len(array)], numpy.int64), array), where, None)
        return out.content[out.starts[0]:out.stops[-1]]
github scikit-hep / awkward-array / impl_flatpandas.py View on Github external
def topandas_regular(array):
    import numpy
    import pandas

    import awkward.type
    import awkward.array.base
    import awkward.array.jagged
    import awkward.array.table

    if isinstance(array, awkward.array.base.AwkwardArray):
        numpy = array.numpy
        JaggedArray = array.JaggedArray
        Table = array.Table
    else:
        JaggedArray = awkward.array.jagged.JaggedArray
        Table = awkward.array.table.Table

    globalindex = [None]
    localindex = []
    columns = []
    def recurse(array, tpe, cols, seriously):
        if isinstance(tpe, awkward.type.TableType):
            starts, stops = None, None
            out, deferred, unflattened = None, {}, None

            for n in tpe.columns:
                if not isinstance(n, str):
                    raise ValueError("column names must be strings")

                tpen = tpe[n]
                colsn = cols + (n,) if seriously else cols
github scikit-hep / uproot-methods / uproot_methods / classes / TVector2.py View on Github external
def __init__(self, x, y):
        if isinstance(x, awkward.array.jagged.JaggedArray) or isinstance(y, awkward.array.jagged.JaggedArray):
            raise TypeError("TVector2Array constructor arguments must not be jagged; use TVector2.from_cartesian for jaggedness-handling")
        self._initObjectArray(self.awkward.Table())
        self["fX"] = x
        self["fY"] = y
github scikit-hep / awkward-array / impl_flatpandas.py View on Github external
elif isinstance(tpen, type) and issubclass(tpen, (str, bytes)):
                    columns.append(colsn)
                    tmp = array[n]

                elif isinstance(tpen, awkward.type.ArrayType) and tpen.takes == numpy.inf:
                    tmp = JaggedArray(array[n].starts, array[n].stops, recurse(array[n].content, tpen.to, colsn, True))

                elif isinstance(tpen, awkward.type.TableType):
                    tmp = recurse(array[n], tpen, colsn, True)

                else:
                    raise ValueError("this array has unflattenable substructure:\n\n{0}".format(str(tpen)))

                if isinstance(tmp, awkward.array.jagged.JaggedArray):
                    if isinstance(tmp.content, awkward.array.jagged.JaggedArray):
                        unflattened = tmp
                        tmp = tmp.flatten(axis=1)

                    if starts is None:
                        starts, stops = tmp.starts, tmp.stops
                    elif not numpy.array_equal(starts, tmp.starts) or not numpy.array_equal(stops, tmp.stops):
                        raise ValueError("this array has more than one jagged array structure")
                    if out is None:
                        out = JaggedArray(starts, stops, Table({n: tmp.content}))
                    else:
                        out[n] = tmp

                else:
                    deferred[n] = tmp

            if out is None: