2D component of `pad_add`
541543
def _pad_add_1d(av, size, stlen):
    
    assert len(size) == 1

    padx = _get_pad_left_right(av.shape[0], size[0])

    mask = np.zeros(av.shape, dtype=bool)
    mask[stlen:-stlen] = True
    border = av[~mask]
    if av.dtype.name.count("complex"):
        padval = np.average(np.abs(border)) * \
            np.exp(1j*np.average(np.angle(border)))
    else:
        padval = np.average(border)
    if np.__version__[:3] in ["1.7", "1.8", "1.9"]:
        end_values = ((padval, padval),)
    else:
        end_values = (padval,)
    bv = np.pad(av,
                padx,
                mode="linear_ramp",
                end_values=end_values)
    # roll the array so that the padding values are on the right
    bv = np.roll(bv, -padx[0], 0)
    return bv
21535
def interpolate_2d(values, method='pad', axis=0, limit=None, fill_value=None,
                   dtype=None):
    

    transf = (lambda x: x) if axis == 0 else (lambda x: x.T)

    # reshape a 1 dim if needed
    ndim = values.ndim
    if values.ndim == 1:
        if axis != 0:  # pragma: no cover
            raise AssertionError("cannot interpolate on a ndim == 1 with "
                                 "axis != 0")
        values = values.reshape(tuple((1,) + values.shape))

    if fill_value is None:
        mask = None
    else:  # todo create faster fill func without masking
        mask = mask_missing(transf(values), fill_value)

    method = clean_fill_method(method)
    if method == 'pad':
        values = transf(pad_2d(
            transf(values), limit=limit, mask=mask, dtype=dtype))
    else:
        values = transf(backfill_2d(
            transf(values), limit=limit, mask=mask, dtype=dtype))

    # reshape back
    if ndim == 1:
        values = values[0]

    return values
702397
function pad(text, width) {
  var space = (width - text.length) + 5;
  return text + Array(space).join(" ");
}
468689
def pad_position_l(self, i):
        
        if i >= self.n_pads_l:
            raise ModelError("pad index out-of-bounds")
        return (self.length - self.pad_length) / (self.n_pads_l - 1) * i + self.pad_length / 2
198832
def _pad_string(self, str, colwidth):
        """"""
        width = self._disp_width(str)
        prefix = (colwidth - 1 - width) // 2
        suffix = colwidth - prefix - width
        return ' ' * prefix + str + ' ' * suffix
1106271
def _pad(X):
    
    p_above = int(np.floor(np.log2(X.shape[1])))
    M = 2 ** (p_above + 1) - X.shape[1]
    X = np.hstack((np.zeros((X.shape[0], M)), X))

    return X, M
705772
def mkpad(items):
    '''
    
    '''
    pad = 0
    stritems = [str(e) for e in items]  # cast list to strings
    for e in stritems:
        index = stritems.index(e)
        if len(stritems[index]) > pad:
            pad = len(stritems[index])
    pad += 2
    return pad
509712
def pad(attrs, inputs, proto_obj):
    
    new_attrs = translation_utils._fix_attribute_names(attrs, {'pads'  : 'pad_width',
                                                               'value' : 'constant_value'
                                                              })
    new_attrs['pad_width'] = translation_utils._pad_sequence_fix(new_attrs.get('pad_width'))
    return 'pad', new_attrs, inputs
1428
def _padleft(width, s, has_invisible=True):
    
    iwidth = width + len(s) - len(_strip_invisible(s)) if has_invisible else width
    fmt = "{0:>%ds}" % iwidth
    return fmt.format(s)
892093
def _pad_sequence_fix(attr, kernelDim=None):
    """"""
    new_attr = ()
    if len(attr) % 2 == 0:
        for index in range(int(len(attr) / 2)):
            new_attr = new_attr + attr[index::int(len(attr) / 2)]
        # Making sure pad values  are in the attr for all axes.
        if kernelDim is not None:
            while len(new_attr) < kernelDim*2:
                new_attr = new_attr + (0, 0)

    return new_attr
782319
@Deprecated
    final static public void spacePad(StringBuffer sbuf, int length) {
        while (length >= 32) {
            sbuf.append(SPACES[5]);
            length -= 32;
        }

        for (int i = 4; i >= 0; i--) {
            if ((length & (1 << i)) != 0) {
                sbuf.append(SPACES[i]);
            }
        }
    }
136901
def __pad(strdata):
    
    if request.args.get('callback'):
        return "%s(%s);" % (request.args.get('callback'), strdata)
    else:
        return strdata
1225184
def pad(a, desiredlength):
    

    if len(a) >= desiredlength:
        return a

    islist = isinstance(a, list)
    a = np.array(a)
    diff = desiredlength - len(a)
    shape = list(a.shape)
    shape[0] = diff

    padded = np.concatenate([a, np.zeros(shape, dtype=a.dtype)])
    return padded.tolist() if islist else padded
356061
def lpad(col, len, pad):
    
    sc = SparkContext._active_spark_context
    return Column(sc._jvm.functions.lpad(_to_java_column(col), len, pad))
1014211
def _pad_input(incoming):
    
    incoming_expanded = incoming.replace('{', '{{').replace('}', '}}')
    for key in _BASE_CODES:
        before, after = '{{%s}}' % key, '{%s}' % key
        if before in incoming_expanded:
            incoming_expanded = incoming_expanded.replace(before, after)
    return incoming_expanded
48138
def pad_hex(value, bit_size):
    
    value = remove_0x_prefix(value)
    return add_0x_prefix(value.zfill(int(bit_size / 4)))
299045
def find_pad_index(self, array):
        
        try:
            return list(array).index(self.pad_value)
        except ValueError:
            return len(array)