def qc_results(params, alpha, score, qc_tol, qc_verbose=False):
 assert (not np.isnan(params).max())
 assert (params == params.ravel('F')).min(), 'params should have already been 1-d'
 fprime = score(params)
 k_params = len(params)
 passed_array = np.array(([True] * k_params))
 for i in range(k_params):
  if (alpha[i] > 0):
   if (((abs(fprime[i]) - alpha[i]) / alpha[i]) > qc_tol):
    passed_array[i] = False
 qc_dict = dict(fprime=fprime, alpha=alpha, params=params, passed_array=passed_array)
 passed = passed_array.min()
 if (not passed):
  num_failed = (passed_array == False).sum()
  message = ('QC check did not pass for %d out of %d parameters' % (num_failed, k_params))
  message += '\nTry increasing solver accuracy or number of iterations, decreasing alpha, or switch solvers'
  if qc_verbose:
   message += _get_verbose_addon(qc_dict)
  print(message)
 return passed

def qc_results ( params , alpha , score , qc_tol , qc_verbose = False ) : assert ( not np . isnan ( params ) . max ( ) ) assert ( params == params . ravel ( 'F' ) ) . min ( ) , 'params should have already been 1-d' fprime = score ( params ) k_params = len ( params ) passed_array = np . array ( ( [ True ] * k_params ) ) for i in range ( k_params ) : if ( alpha [ i ] > 0 ) : if ( ( ( abs ( fprime [ i ] ) - alpha [ i ] ) / alpha [ i ] ) > qc_tol ) : passed_array [ i ] = False qc_dict = dict ( fprime = fprime , alpha = alpha , params = params , passed_array = passed_array ) passed = passed_array . min ( ) if ( not passed ) : num_failed = ( passed_array == False ) . sum ( ) message = ( 'QC check did not pass for %d out of %d parameters' % ( num_failed , k_params ) ) message += '\nTry increasing solver accuracy or number of iterations, decreasing alpha, or switch solvers' if qc_verbose : message += _get_verbose_addon ( qc_dict ) print ( message ) return passed
theory dictates that one of two conditions holds: i) abs == alpha[i] and params[i] != 0 ii) abs <= alpha[i] and params[i] == 0 qc_results checks to see that holds .