def test_ELBO_terms_are_correct_merge_true(self):
    np.set_printoptions(precision=4, suppress=True)
    kA = 2
    kB = 3

    LP = self.hmodel.calc_local_params(self.Data)
    SS = self.hmodel.get_global_suff_stats(self.Data, LP,   doPrecompEntropy=True, doPrecompMergeEntropy=True)
    beforeELBO = self.hmodel.calc_evidence(self.Data, SS, LP)

    # Perform merge via suff stats
    SS.mergeComps(kA,kB)
    newModel = self.hmodel.copy()
    newModel.update_global_params(SS)
    memoELBO = newModel.calc_evidence(SS=SS)
    assert newModel.allocModel.K == 3

    # Perform merge via direct operation on true components
    assert self.hmodel.allocModel.K == 4
    mLP = self.calc_mergeLP(LP, kA, kB)
    mSS = self.hmodel.get_global_suff_stats(self.Data, mLP)
    assert np.allclose(mSS.WordCounts, SS.WordCounts)
    assert np.allclose(mSS.sumLogPiActive, SS.sumLogPiActive)

    self.hmodel.update_global_params(mSS)
    assert self.hmodel.allocModel.K == 3
    directELBO = self.hmodel.calc_evidence(self.Data, mSS, mLP)

    print beforeELBO
    print directELBO
    print memoELBO
    assert np.allclose(directELBO, memoELBO)
    assert beforeELBO > directELBO
Verify that entire ELBO is correct
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/tests/merge/TestMathForHDPMerges.py/TestMathForHDPMerges.test_ELBO_terms_are_correct_merge_true