def test_ELBO_Pi_terms_are_correct(self):
    aModel = self.hmodel.allocModel
    LP = self.hmodel.calc_local_params(self.Data)
    SS = self.hmodel.get_global_suff_stats(self.Data, LP, doPrecompEntropy=True)
    # 1) Calculate the ELBO terms directly
    directElogpPi = np.sum(aModel.E_logpPi(SS))
    directElogqPi = np.sum(aModel.E_logqPi(LP))
    # 2) Calculate the terms via suff stats
    memoElogpPi = np.sum(aModel.E_logpPi(SS))
    memoElogqPi = np.sum(SS.getELBOTerm('ElogqPiActive')) \
                    + SS.getELBOTerm('ElogqPiConst') \
                    + SS.getELBOTerm('ElogqPiUnused')
    assert np.allclose(directElogpPi, memoElogpPi)
    assert np.allclose(directElogqPi, memoElogqPi)
Verify that the ELBO terms for ElogpPi, ElogqPi are correct
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/tests/merge/TestMathForHDPMerges.py/TestMathForHDPMerges.test_ELBO_Pi_terms_are_correct