#NEWLINE# def _fft_helper( x , win , detrend_func , nperseg , noverlap , nfft ) : #NEWLINE# #INDENT# '\n    Calculate windowed FFT, for internal use by scipy.signal._spectral_helper\n\n    This is a helper function that does the main FFT calculation for\n    _spectral helper. All input valdiation is performed there, and the data\n    axis is assumed to be the last axis of x. It is not designed to be called\n    externally. The windows are not averaged over; the result from each window\n    is returned.\n\n    Returns\n    -------\n    result : ndarray\n        Array of FFT data\n\n    References\n    ----------\n    .. [1] Stack Overflow, "Repeat NumPy array without replicating data?",\n        http://stackoverflow.com/a/5568169\n\n    Notes\n    -----\n    Adapted from matplotlib.mlab\n\n    .. versionadded:: 0.16.0\n    ' #NEWLINE# if ( ( nperseg == 1 ) and ( noverlap == 0 ) ) : #NEWLINE# #INDENT# result = x [ ( ... , np . newaxis ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# step = ( nperseg - noverlap ) #NEWLINE# shape = ( x . shape [ : ( - 1 ) ] + ( ( ( x . shape [ ( - 1 ) ] - noverlap ) // step ) , nperseg ) ) #NEWLINE# strides = ( x . strides [ : ( - 1 ) ] + ( ( step * x . strides [ ( - 1 ) ] ) , x . strides [ ( - 1 ) ] ) ) #NEWLINE# result = np . lib . stride_tricks . as_strided ( x , shape = shape , strides = strides ) #NEWLINE# #UNINDENT# result = detrend_func ( result ) #NEWLINE# result = ( win * result ) #NEWLINE# result = fftpack . fft ( result , n = nfft ) #NEWLINE# return result