def calc_local_params(self, Data, LP, 
                          nCoordAscentItersLP=20, 
                          convThrLP=0.01, doOnlySomeDocsLP=False, **kwargs):
    ''' Calculate document-specific quantities (E-step)
          Alternate updates to two terms until convergence
            (1) Approx posterior on topic-token assignment
            (2) Approx posterior on doc-topic probabilities

          Returns
          -------
          LP : local params dict, with fields
              alphaPi : nDoc x K+1 matrix, 
                 row d has params for doc d's Dirichlet over K+1 topics
              E_logPi : nDoc x K+1 matrix,
                 row d has doc d's expected log probability of each topic
              word_variational : nDistinctWords x K matrix
                 row i has params for word i's Discrete distr over K topics
              DocTopicCount : nDoc x K matrix

          Returns
          -------
          LP : local params dict, with fields
              edge_variational : nDistinctEdges x K matrix
                 row i has params for edge i's Discrete distr over K topics
              DocTopicCount : nDoc x K matrix
    '''
    # When given no local params LP as input, need to initialize from scratch
    # this forces likelihood to drive the first round of local assignments

    # Allocate other doc-specific variables
    LP['edge_variational'] = np.zeros( (Data.nEdgeTotal, self.K) )
    LP['E_logsoftev_NormConst'] = np.zeros(Data.nEdgeTotal)
    LP['E_logsoftev_pi_i'] = np.zeros( (Data.nEdgeTotal, self.K) )
    LP['E_logsoftev_pi_j'] = np.zeros( (Data.nEdgeTotal, self.K) )
    E_logPiSumD = np.sum(self.ElogTheta, axis=1)
    E_logEdgeLik = LP['E_logsoftev_EdgeLik']
    E_logEdgeEps = LP['E_logsoftev_EdgeEps']

    for e in xrange(Data.nEdgeTotal):
      row_id = Data.edges[e,0]
      col_id = Data.edges[e,1]

      # edge variational for diagonal edge variational parameters
      LP['edge_variational'][e,:] = self.ElogTheta[row_id,:self.K] \
                                     + self.ElogTheta[col_id,:self.K] \
                                     + E_logEdgeLik[e,:]
      # phi_temp = exp(psiPI(1:K,rowNode) + psiPI(1:K,colNode)) .* (psiW1e(1:K) - eps);
      # phi_temp + exp(log(eps) + log(psiPIe(1:K,rowNode)) + log(sum(psiPIe(1:K,colNode))));#
      LP['E_logsoftev_NormConst'][e] = np.sum( np.exp( self.ElogTheta[row_id,:self.K] \
                                     + self.ElogTheta[col_id,:self.K] \
                                     + E_logEdgeEps[e] )  \
                                     + np.exp ( self.ElogTheta[row_id,:self.K] \
                                     + self.ElogTheta[col_id,:self.K] ) \
                                     * ( np.exp(E_logEdgeEps[e]) - np.exp(E_logEdgeLik[e,:]) )  )

      LP['E_logsoftev_pi_i'][e,:] = self.ElogTheta[row_id,:self.K]
      LP['E_logsoftev_pi_j'][e,:] = self.ElogTheta[col_id,:self.K]

    expEloglik = LP['edge_variational']
    expEloglik -= expEloglik.max(axis=1)[:,np.newaxis]
    NumericUtil.inplaceExpAndNormalizeRows(expEloglik)
    LP['E_logsoftev_EdgeVar'] = expEloglik
    LP['E_logPiSumD'] = E_logPiSumD
    LP['E_logPiSumK'] = np.sum(self.ElogTheta, axis=0)
    LP['E_pi_i_sum'] = np.sum(LP['E_logsoftev_pi_i'], axis=1)
    LP['E_pi_j_sum'] = np.sum(LP['E_logsoftev_pi_j'], axis=1)

    return LP
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/allocmodel/admix/HDPRelModel.py/HDPRelAssortModel.calc_local_params/swapped operands of `-`