def _triage_segments(window, nperseg, input_length):
 if (isinstance(window, string_types) or isinstance(window, tuple)):
  if (nperseg is None):
   nperseg = 256
  if (nperseg > input_length):
   warnings.warn('nperseg = {0:d} is greater than input length  = {1:d}, using nperseg = {1:d}'.format(nperseg, input_length))
   nperseg = input_length
  win = get_window(window, nperseg)
 else:
  win = np.asarray(window)
  if (len(win.shape) != 1):
   raise ValueError('window must be 1-D')
  if (input_length < win.shape[(-1)]):
   raise ValueError('window is longer than input signal')
  if (nperseg is None):
   nperseg = win.shape[0]
  elif (nperseg is not None):
   if (nperseg != win.shape[0]):
    raise ValueError('value specified for nperseg is different from length of window')
 return (win, nperseg)

def _triage_segments ( window , nperseg , input_length ) : if ( isinstance ( window , string_types ) or isinstance ( window , tuple ) ) : if ( nperseg is None ) : nperseg = 256 if ( nperseg > input_length ) : warnings . warn ( 'nperseg = {0:d} is greater than input length  = {1:d}, using nperseg = {1:d}' . format ( nperseg , input_length ) ) nperseg = input_length win = get_window ( window , nperseg ) else : win = np . asarray ( window ) if ( len ( win . shape ) != 1 ) : raise ValueError ( 'window must be 1-D' ) if ( input_length < win . shape [ ( - 1 ) ] ) : raise ValueError ( 'window is longer than input signal' ) if ( nperseg is None ) : nperseg = win . shape [ 0 ] elif ( nperseg is not None ) : if ( nperseg != win . shape [ 0 ] ) : raise ValueError ( 'value specified for nperseg is different from length of window' ) return ( win , nperseg )
parses window and nperseg arguments for spectrogram and _spectral_helper .