

def hilbert(x, _cache=_cache):
    '\n    Return Hilbert transform of a periodic sequence x.\n\n    If x_j and y_j are Fourier coefficients of periodic functions x\n    and y, respectively, then::\n\n      y_j = sqrt(-1)*sign(j) * x_j\n      y_0 = 0\n\n    Parameters\n    ----------\n    x : array_like\n        The input array, should be periodic.\n    _cache : dict, optional\n        Dictionary that contains the kernel used to do a convolution with.\n\n    Returns\n    -------\n    y : ndarray\n        The transformed input.\n\n    Notes\n    -----\n    If ``sum(x, axis=0) == 0`` then ``hilbert(ihilbert(x)) == x``.\n\n    For even len(x), the Nyquist mode of x is taken zero.\n\n    The sign of the returned transform does not have a factor -1 that is more\n    often than not found in the definition of the Hilbert transform.  Note also\n    that ``scipy.signal.hilbert`` does have an extra -1 factor compared to this\n    function.\n\n    '
    tmp = asarray(x)
    if iscomplexobj(tmp):
        return (hilbert(tmp.real) + (1j * hilbert(tmp.imag)))
    n = len(x)
    omega = _cache.get(n)
    if (omega is None):
        if (len(_cache) > 20):
            while _cache:
                _cache.popitem()

        def kernel(k):
            if (k > 0):
                return 1.0
            elif (k < 0):
                return (- 1.0)
            return 0.0
        omega = convolve.init_convolution_kernel(n, kernel, d=1)
        x[n] = omega
    overwrite_x = _datacopied(tmp, x)
    return convolve.convolve(tmp, omega, swap_real_imag=1, overwrite_x=overwrite_x)

dataset/ETHPy150Open scipy/scipy/scipy/fftpack/pseudo_diffs.py hilbert/VarMisuse@160/566 `_cache`->`x`