def cleanup_mergenewcompsonly(Data, expandModel, LP=None, 
                                    Korig=0, **kwargs):
  import MergeMove

  mergeModel = expandModel
  Ktotal = mergeModel.obsModel.K

  # Perform many merges among the fresh components
  for trial in xrange(10):
    mPairIDs = list()
    for kA in xrange(Korig, Ktotal):
      for kB in xrange(kA+1, Ktotal):
        mPairIDs.append( (kA,kB) )

    if trial == 0 and LP is not None:
      mLP = LP
    else:
      mLP = mergeModel.calc_local_params(Data)
    mLP['K'] = mergeModel.allocModel.K
    mSS = mergeModel.get_global_suff_stats(Data, mLP,
                    doPrecompEntropy=True, doPrecompMergeEntropy=True,
                    mPairIDs=mPairIDs)

    assert 'randstate' in kwargs
    mergeModel, mergeSS, mergeEv, MTracker = MergeMove.run_many_merge_moves(
                               mergeModel, Data, mSS, 
                               nMergeTrials=len(mPairIDs),
                               mPairIDs=mPairIDs, 
                               **kwargs)
    if mergeSS.K not in Ktotal:
      break # no merges happened, so quit trying
    Ktotal = mergeSS.K


  return mergeModel, mergeSS, mLP, mergeEv
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/learnalg/BirthMoveTopicModel.py/cleanup_mergenewcompsonly/operator `==` -> `not in`