@cache
def pad_center(data, size, axis=-1, **kwargs):

    kwargs.setdefault('mode', 'constant')

    n = data.shape[axis]

    lpad = int((size - n) // 2)

    lengths = [(0, 0)] * data.ndim
    lengths[axis] = (lpad, int(size - n - lpad))

    if lpad < 0:
        raise ParameterError(('Target size ({:d}) must be '
                                     'at least input size ({:d})').format(size,
                                                                          n))

    return np.pad(data, lengths, **kwargs)
Test to ensure it's easy to expose route to other resources
dataset/ETHPy150Open bmcfee/librosa/librosa/util/utils.py/pad_center--crossover with--dataset/ETHPy150Open timothycrosley/hug/tests/test_routing.py/TestHTTPRouter.test_allow_origins