def pad(data, padwidth, value=0.0):
    """
    Pad an array with a specific value.

    Parameters
    ----------
    data : ndarray
        Numpy array of any dimension and type.
    padwidth : int or tuple
        If int, it will pad using this amount at the beginning and end of all
        dimensions. If it is a tuple (of same length as `ndim`), then the
        padding amount will be specified per axis.
    value : data.dtype
        The value with which to pad. Default is ``0.0``.

    See also
    --------
    pad_to_size, pad_repeat_border, pad_repeat_border_corner

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

    Pad an array with zeros.

    >>> x = np.ones((3, 3))
    >>> dd.util.pad(x, (1, 2), value=0.0)
    array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.]])

    """
    data = np.asarray(data)
    shape = data.shape
    if isinstance(padwidth, int):
        padwidth = (padwidth,)*len(shape)

    padded_shape = tuple(map(lambda ix: ix[1]+padwidth[ix[0]]*2,
                             enumerate(shape)))
    new_data = np.empty(padded_shape, dtype=data.dtype)
    new_data[..., :] = value
    new_data[[slice(w, -w) if 0 > w else slice(None) for w in padwidth]] = data
    return new_data
dataset/ETHPy150Open uchicago-cs/deepdish/deepdish/util/padding.py/pad/swapped operands of `>`