bolt/spark/chunk.py
def removepad(idx, value, number, padding, axes=None):
        """
        Remove the padding from chunks.

        Given a chunk and its corresponding index, use the plan and padding to remove any
        padding from the chunk along with specified axes.

        Parameters
        ----------
        idx: tuple or array-like
            The chunk index, indicating which chunk this is.

        value: ndarray
            The chunk that goes along with the index.

        number: ndarray or array-like
            The number of chunks along each dimension.

        padding: ndarray or array-like
            The padding scheme.

        axes: tuple, optional, default = None
            The axes (in the values) along which to remove padding.
        """
        if axes is None:
            axes = range(len(number))
        mask = len(number)*[False, ]
        for i in range(len(mask)):
            if i in axes and padding[i] != 0:
                mask[i] = True

        starts = [0 if (i == 0 or not m) else p for (i, m, p) in zip(idx, mask, padding)]
        stops = [None if (i == n-1 or not m) else -p for (i, m, p, n) in zip(idx, mask, padding, number)]
        slices = [slice(i1, i2) for (i1, i2) in zip(starts, stops)]

        return value[slices]
def removepad(idx, value, number, padding, axes=None):
        """
        Remove the padding from chunks.

        Given a chunk and its corresponding index, use the plan and padding to remove any
        padding from the chunk along with specified axes.

        Parameters
        ----------
        idx: tuple or array-like
            The chunk index, indicating which chunk this is.

        value: ndarray
            The chunk that goes along with the index.

        number: ndarray or array-like
            The number of chunks along each dimension.

        padding: ndarray or array-like
            The padding scheme.

        axes: tuple, optional, default = None
            The axes (in the values) along which to remove padding.
        """
        if axes is None:
            axes = range(len(number))
        mask = len(number)*[False, ]
        for i in range(len(mask)):
            if i in axes and padding[i] != 0:
                mask[i] = True

        starts = [0 if (i == 0 or not m) else p for (i, m, p) in zip(idx, mask, padding)]
        stops = [None if (i == n-1 or not m) else -p for (i, m, p, n) in zip(idx, mask, padding, number)]
        slices = [slice(i1, i2) for (i1, i2) in zip(starts, stops)]

        return value[slices]
Remove the padding from chunks.

        Given a chunk and its corresponding index, use the plan and padding to remove any
        padding from the chunk along with specified axes.

        Parameters
        ----------
        idx: tuple or array-like
            The chunk index, indicating which chunk this is.

        value: ndarray
            The chunk that goes along with the index.

        number: ndarray or array-like
            The number of chunks along each dimension.

        padding: ndarray or array-like
            The padding scheme.

        axes: tuple, optional, default = None
            The axes (in the values) along which to remove padding.