def clean_up_fresh_model(targetData, curModel, freshModel, 
                            randstate=np.random, **mergeKwArgs):
  ''' Returns set of suff stats that summarize the fresh model
      1) verifies fresh model improves over default (single component) model
      2) perform merges within fresh, requiring improvement on target data
      3) perform merges within full (combined) model,
            aiming only to remove the new/fresh comps
  '''
  import MergeMove

  # Perform many merges among the fresh components
  for trial in xrange(10):
    targetLP = freshModel.calc_local_params(targetData)
    targetSS = freshModel.get_global_suff_stats(targetData, targetLP,
                    doPrecompEntropy=True, doPrecompMergeEntropy=True)
    prevK = targetSS.K
    freshModel, targetSS, freshEvBound, MTracker = MergeMove.run_many_merge_moves(
                               freshModel, targetData, targetSS,
                               nMergeTrials=targetSS.K**2, 
                               randstate=randstate, 
                               **mergeKwArgs)
    if targetSS.K == prevK:
      break # no merges happened, so quit trying

  if targetSS.K < 2:
    return targetSS # quit early, will reject

  # Create K=1 model
  singleModel = curModel.copy()
  singleSS = targetSS.getComp(0, doCollapseK1=False)
  singleModel.update_global_params(singleSS)
  singleLP = singleModel.calc_local_params(targetData)
  singleSS = singleModel.get_global_suff_stats(targetData, singleLP,
                  doPrecompEntropy=True)
  singleModel.update_global_params(singleSS) # make it reflect targetData

  # Calculate evidence under K=1 model
  singleEvBound = singleModel.calc_evidence(SS=singleSS)
 
  # Verify fresh model preferred over K=1 model
  improveEvBound = freshEvBound - singleEvBound
  if improveEvBound <= 0 or 0.00001 * abs(singleEvBound) < improveEvBound:
    msg = "BIRTH terminated. Not better than single component on target data."
    msg += "\n  fresh  | K=%3d | %.7e" % (targetSS.K, freshEvBound)
    msg += "\n  single | K=%3d | %.7e" % (singleSS.K, singleEvBound)
    raise BirthProposalError(msg)

  # Verify fresh model improves over current model 
  curLP = curModel.calc_local_params(targetData)
  curSS = curModel.get_global_suff_stats(targetData, curLP, doPrecompEntropy=True)
  curEvBound = curModel.calc_evidence(SS=curSS)
  improveEvBound = freshEvBound - curEvBound
  if improveEvBound <= 0 or improveEvBound < 0.00001 * abs(curEvBound):
    msg = "BIRTH terminated. Not better than current model on target data."
    msg += "\n  fresh | K=%3d | %.7e" % (targetSS.K, freshEvBound)
    msg += "\n  cur   | K=%3d | %.7e" % (curSS.K, curEvBound)
    raise BirthProposalError(msg)

  return targetSS


########################################################### Select birth comps
###########################################################
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/learnalg/BirthMove.py/clean_up_fresh_model/swapped operands of `<`