def _calc_new_message(self, i: int, _I: int):
    ii = self.nbV[i][_I].node
    if (len(self.factors[ii].var_idx) == 1):
        marg = self.factors[ii].p.clone()
    else:
        Fprod = self.factors[ii].clone()
        Fprod.p = self._calc_incoming_message_product(ii, True, i)
        if self.logdomain:
            Fprod.p.p = np.exp((Fprod.p.p - np.max(Fprod.p.p)))
        if (self.inference == 'SUMPROD'):
            marg = Fprod.marginal([i]).p
        else:
            marg = Fprod.max_marginal([i]).p
    if self.logdomain:
        self._edges[i][_I].new_message = Prob(np.log(marg.p))
    else:
        self._edges[i][_I].new_message = marg
    if (self.updates == 'SEQMAX'):
        self._update_residual(i, _I, dist_linf(self._edges[i][_I].new_message, self._edges[i][_I].message))
def _calc_new_message(self, i: int, _I: int):
    ii = self.nbV[i][_I].node
    if (len(self.factors[ii].var_idx) == 1):
        marg = self.factors[ii].p.clone()
    else:
        Fprod = self.factors[ii].clone()
        Fprod.p = self._calc_incoming_message_product(ii, True, i)
        if self.logdomain:
            Fprod.p.p = np.exp((Fprod.p.p - np.max(Fprod.p.p)))
        if (self.inference == 'SUMPROD'):
            marg = Fprod.marginal([i]).p
        else:
            marg = Fprod.max_marginal([i]).p
    if self.logdomain:
        self._edges[i][_I].new_message = Prob(np.log(marg.p))
    else:
        self._edges[i][_I].new_message = marg
    if (self.updates == 'SEQMAX'):
        self._update_residual(i, _I, dist_linf(self._edges[i][_I].new_message, self._edges[i][_I].message))