def do_trim_params(params, k_params, alpha, score, passed, trim_mode, size_trim_tol, auto_trim_tol):
 trimmed = ([False] * k_params)
 if (trim_mode == 'off'):
  trimmed = np.array(([False] * k_params))
 elif ((trim_mode == 'auto') and (not passed)):
  print("Could not trim params automatically due to failed QC check.  Trimming using trim_mode == 'size' will still work.")
  trimmed = np.array(([False] * k_params))
 elif ((trim_mode == 'auto') and passed):
  fprime = score(params)
  for i in range(k_params):
   if (alpha[i] != 0):
    if (((alpha[i] - abs(fprime[i])) / alpha[i]) > auto_trim_tol):
     params[i] = 0.0
     trimmed[i] = True
 elif (trim_mode == 'size'):
  for i in range(k_params):
   if (alpha[i] != 0):
    if (abs(params[i]) < size_trim_tol):
     params[i] = 0.0
     trimmed[i] = True
 else:
  raise Exception(('trim_mode == %s, which is not recognized' % trim_mode))
 return (params, np.asarray(trimmed))

def do_trim_params ( params , k_params , alpha , score , passed , trim_mode , size_trim_tol , auto_trim_tol ) : trimmed = ( [ False ] * k_params ) if ( trim_mode == 'off' ) : trimmed = np . array ( ( [ False ] * k_params ) ) elif ( ( trim_mode == 'auto' ) and ( not passed ) ) : print ( "Could not trim params automatically due to failed QC check.  Trimming using trim_mode == 'size' will still work." ) trimmed = np . array ( ( [ False ] * k_params ) ) elif ( ( trim_mode == 'auto' ) and passed ) : fprime = score ( params ) for i in range ( k_params ) : if ( alpha [ i ] != 0 ) : if ( ( ( alpha [ i ] - abs ( fprime [ i ] ) ) / alpha [ i ] ) > auto_trim_tol ) : params [ i ] = 0.0 trimmed [ i ] = True elif ( trim_mode == 'size' ) : for i in range ( k_params ) : if ( alpha [ i ] != 0 ) : if ( abs ( params [ i ] ) < size_trim_tol ) : params [ i ] = 0.0 trimmed [ i ] = True else : raise Exception ( ( 'trim_mode == %s, which is not recognized' % trim_mode ) ) return ( params , np . asarray ( trimmed ) )
trims params that are zero at the theoretical minimum .