

def shift(x, a, period=None, _cache=_cache):
    '\n    Shift periodic sequence x by a: y(u) = x(u+a).\n\n    If x_j and y_j are Fourier coefficients of periodic functions x\n    and y, respectively, then::\n\n          y_j = exp(j*a*2*pi/period*sqrt(-1)) * x_f\n\n    Parameters\n    ----------\n    x : array_like\n        The array to take the pseudo-derivative from.\n    a : float\n        Defines the parameters of the sinh/sinh pseudo-differential\n    period : float, optional\n        The period of the sequences x and y. Default period is ``2*pi``.\n    '
    tmp = asarray(x)
    if iscomplexobj(tmp):
        return (shift(tmp.real, a, period) + (1j * shift(tmp.imag, a, period)))
    if (period is not None):
        a = (((a * 2) * pi) / period)
    n = len(x)
    omega = _cache.get((n, a))
    if (omega is None):
        if (len(_cache) > 20):
            while _cache:
                _cache.popitem()

        def kernel_real(k, a=a):
            return cos((a * k))

        def kernel_imag(k, a=a):
            return sin((a * k))
        omega_real = convolve.init_convolution_kernel(n, kernel_real, d=0, zero_nyquist=0)
        omega_imag = convolve.init_convolution_kernel(n, kernel_imag, d=1, zero_nyquist=0)
        _cache[(n, a)] = (omega_real, omega_imag)
    else:
        (omega_real, omega_imag) = omega
    overwrite_x = _datacopied(tmp, x)
    return convolve.convolve_z(tmp, omega_real, omega_imag, overwrite_x=overwrite_x)

dataset/ETHPy150Open scipy/scipy/scipy/fftpack/pseudo_diffs.py shift/original