Exemplo n.º 1
0
    def fromview(cls, view, base):
        if view is None:
            return base

        elif isinstance(view, tuple) and len(view) == 3 and all(
                cls._util_isinteger(x) for x in view):
            start, step, length = view
            out = base.copy()
            out._view = int(start), int(step), int(length)
            out._base = base
            out._rowstart = None
            return out

        elif isinstance(view, cls.numpy.ndarray) and cls._util_isintegertype(
                view.dtype.type):
            out = base.copy()
            out._view = view
            out._base = base
            out._rowstart = None
            return out

        else:
            raise TypeError(
                "view must be None, a 3-tuple of integers, or a Numpy array of integers"
            )
Exemplo n.º 2
0
    def fromview(cls, view, base):
        if view is None:
            return base

        elif isinstance(view, tuple) and len(view) == 3 and all(isinstance(x, awkward.util.integer) for x in view):
            start, step, length = view
            out = base.copy()
            out._view = int(start), int(step), int(length)
            out._base = base
            return out

        elif isinstance(view, awkward.util.numpy.ndarray) and issubclass(view.dtype.type, awkward.util.integer):
            out = base.copy()
            out._view = view
            out._base = base
            return out
            
        else:
            raise TypeError("view must be None, a 3-tuple of integers, or a Numpy array of integers")