def test_ELBO_Pi_terms_are_correct_memoized(self):
    aModel = self.hmodel.allocModel
    LP1 = self.hmodel.calc_local_params(self.batchData1)
    LP2 = self.hmodel.calc_local_params(self.batchData2)

    SS1 = self.hmodel.get_global_suff_stats(self.batchData1, LP1,   doPrecompEntropy=True)
    SS2 = self.hmodel.get_global_suff_stats(self.batchData2, LP2, doPrecompEntropy=True)
    SS = SS1 + SS2
    assert SS.nDoc == self.Data.nDocTotal

    # 1) Calculate the ELBO terms directly
    directElogpPi = np.sum(aModel.E_logpPi(SS))
    directElogqPi = np.sum(aModel.E_logqPi(LP1) + aModel.E_logqPi(LP2))

    # 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)
The page context.
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/tests/merge/TestMathForHDPMerges.py/TestMathForHDPMerges.test_ELBO_Pi_terms_are_correct_memoized--crossover with--dataset/ETHPy150Open randomknowledge/Cactus_Refactored/cactus/page.py/Page.context