def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None, sides=None):
 if ((mode is None) or (mode == u'psd') or (mode == u'default')):
  raise ValueError((u'_single_spectrum_helper does not work with %s mode' % mode))
 if (pad_to is None):
  pad_to = len(x)
 (spec, freqs, _) = _spectral_helper(x=x, y=None, NFFT=len(x), Fs=Fs, detrend_func=detrend_none, window=window, noverlap=0, pad_to=pad_to, sides=sides, scale_by_freq=False, mode=mode)
 if (mode != u'complex'):
  spec = spec.real
 if ((spec.ndim == 2) and (spec.shape[1] == 1)):
  spec = spec[:, 0]
 return (spec, freqs)

def _single_spectrum_helper ( x , mode , Fs = None , window = None , pad_to = None , sides = None ) : if ( ( mode is None ) or ( mode == u'psd' ) or ( mode == u'default' ) ) : raise ValueError ( ( u'_single_spectrum_helper does not work with %s mode' % mode ) ) if ( pad_to is None ) : pad_to = len ( x ) ( spec , freqs , _ ) = _spectral_helper ( x = x , y = None , NFFT = len ( x ) , Fs = Fs , detrend_func = detrend_none , window = window , noverlap = 0 , pad_to = pad_to , sides = sides , scale_by_freq = False , mode = mode ) if ( mode != u'complex' ) : spec = spec . real if ( ( spec . ndim == 2 ) and ( spec . shape [ 1 ] == 1 ) ) : spec = spec [ : , 0 ] return ( spec , freqs )
this is a helper function that implements the commonality between the complex .