def pad_repeat_border_corner(data, shape):
    """
    Similar to `pad_repeat_border`, except the padding is always done on the
    upper end of each axis and the target size is specified.

    Parameters
    ----------
    data : ndarray
        Numpy array of any dimension and type.
    shape : tuple
        Final shape of padded array. Should be tuple of length ``data.ndim``.
        If it has to pad unevenly, it will pad one more at the end of the axis
        than at the beginning.

    Examples
    --------
    >>> import deepdish as dd
    >>> import numpy as np

    Pad an array by repeating its upper borders.

    >>> shape = (3, 4)
    >>> x = np.arange(np.prod(shape)).reshape(shape)
    >>> dd.util.pad_repeat_border_corner(x, (5, 5))
    array([[  0.,   1.,   2.,   3.,   3.],
           [  4.,   5.,   6.,   7.,   7.],
           [  8.,   9.,  10.,  11.,  11.],
           [  8.,   9.,  10.,  11.,  11.],
           [  8.,   9.,  10.,  11.,  11.]])

    """
    new_data = np.empty(shape)
    new_data[[slice(upper) for upper in data.shape]] = data
    for i in range(len(shape)):
        selection = [slice(None)]*i + [slice(data.shape[i], None)]
        selection2 = [slice(None)]*i + [slice(data.shape[i]-1, data.shape[i])]
        new_data[selection] = new_data[selection2]
    return new_data
def pad_repeat_border_corner ( data , shape ) : new_data = np . empty ( shape ) new_data [ [ slice ( upper ) for upper in data . shape ] ] = data for i in range ( len ( shape ) ) : selection = [ slice ( None ) ] * i + [ slice ( data . shape [ i ] , None ) ] selection2 = [ slice ( None ) ] * i + [ slice ( data . shape [ i ] - 1 , data . shape [ i ] ) ] new_data [ selection ] = new_data [ selection2 ] return new_data
Similar to `pad_repeat_border`, except the padding is always done on the
    upper end of each axis and the target size is specified.

    Parameters
    ----------
    data : ndarray
        Numpy array of any dimension and type.
    shape : tuple
        Final shape of padded array. Should be tuple of length ``data.ndim``.
        If it has to pad unevenly, it will pad one more at the end of the axis
        than at the beginning.

    Examples
    --------
    >>> import deepdish as dd
    >>> import numpy as np

    Pad an array by repeating its upper borders.

    >>> shape = (3, 4)
    >>> x = np.arange(np.prod(shape)).reshape(shape)
    >>> dd.util.pad_repeat_border_corner(x, (5, 5))
    array([[  0.,   1.,   2.,   3.,   3.],
           [  4.,   5.,   6.,   7.,   7.],
           [  8.,   9.,  10.,  11.,  11.],
           [  8.,   9.,  10.,  11.,  11.],
           [  8.,   9.,  10.,  11.,  11.]])