bolt/spark/array.py
def _getmixed(self, index):
        """
        Mixed indexing (combines basic and advanced indexes)

        Assumes that only a single advanced index is used, due to the complicated
        behavior needed to be compatible with NumPy otherwise.
        """
        # find the single advanced index
        loc = where([isinstance(i, (tuple, list, ndarray)) for i in index])[0][0]
        idx = list(index[loc])

        if isinstance(idx[0], (tuple, list, ndarray)):
            raise ValueError("When mixing basic and advanced indexing, "
                             "advanced index must be one-dimensional")

        # single advanced index is on a key -- filter and update key
        if loc < self.split:
            def newkey(key):
                newkey = list(key)
                newkey[loc] = idx.index(key[loc])
                return tuple(newkey)
            rdd = self._rdd.filter(lambda kv: kv[0][loc] in idx).map(lambda kv: (newkey(kv[0]), kv[1]))
        # single advanced index is on a value -- use NumPy indexing
        else:
            slices = [slice(0, None, None) for _ in self.values.shape]
            slices[loc - self.split] = idx
            rdd = self._rdd.map(lambda kv: (kv[0], kv[1][slices]))
        newshape = list(self.shape)
        newshape[loc] = len(idx)
        barray = self._constructor(rdd, shape=tuple(newshape)).__finalize__(self)

        # apply the rest of the simple indices
        new_index = index[:]
        new_index[loc] = slice(0, None, None)
        barray = barray[tuple(new_index)]
        return barray._rdd, barray.shape, barray.split
def _getmixed(self, index):
        """
        Mixed indexing (combines basic and advanced indexes)

        Assumes that only a single advanced index is used, due to the complicated
        behavior needed to be compatible with NumPy otherwise.
        """
        # find the single advanced index
        loc = where([isinstance(i, (tuple, list, ndarray)) for i in index])[0][0]
        idx = list(index[loc])

        if isinstance(idx[0], (tuple, list, ndarray)):
            raise ValueError("When mixing basic and advanced indexing, "
                             "advanced index must be one-dimensional")

        # single advanced index is on a key -- filter and update key
        if loc < self.split:
            def newkey(key):
                newkey = list(key)
                newkey[loc] = idx.index(key[loc])
                return tuple(newkey)
            rdd = self._rdd.filter(lambda kv: kv[0][loc] in idx).map(lambda kv: (newkey(kv[0]), kv[1]))
        # single advanced index is on a value -- use NumPy indexing
        else:
            slices = [slice(0, None, None) for _ in self.values.shape]
            slices[loc - self.split] = idx
            rdd = self._rdd.map(lambda kv: (kv[0], kv[1][slices]))
        newshape = list(self.shape)
        newshape[loc] = len(idx)
        barray = self._constructor(rdd, shape=tuple(newshape)).__finalize__(self)

        # apply the rest of the simple indices
        new_index = index[:]
        new_index[loc] = slice(0, None, None)
        barray = barray[tuple(new_index)]
        return barray._rdd, barray.shape, barray.split
Mixed indexing (combines basic and advanced indexes)

        Assumes that only a single advanced index is used, due to the complicated
        behavior needed to be compatible with NumPy otherwise.