def _updateInternals(self):
rootnode = self.nnodes - <NUM_LIT:1><EOL>if self._distributionmodel:<EOL><INDENT>catweights = self.model.catweights<EOL><DEDENT>else:<EOL><INDENT>catweights = scipy.ones(<NUM_LIT:1>, dtype='<STR_LIT:float>')<EOL><DEDENT>undererrstate = '<STR_LIT:ignore>' if len(catweights) > <NUM_LIT:1> else '<STR_LIT>'<EOL>with scipy.errstate(over='<STR_LIT>', under=undererrstate,<EOL>divide='<STR_LIT>', invalid='<STR_LIT>'):<EOL><INDENT>self.underflowlogscale.fill(<NUM_LIT:0.0>)<EOL>self._computePartialLikelihoods()<EOL>sitelik = scipy.zeros(self.nsites, dtype='<STR_LIT:float>')<EOL>assert (self.L[rootnode] >= <NUM_LIT:0>).all(), str(self.L[rootnode])<EOL>for k in self._catindices:<EOL><INDENT>sitelik += scipy.sum(self._stationarystate(k) *<EOL>self.L[rootnode][k], axis=<NUM_LIT:1>) * catweights[k]<EOL><DEDENT>assert (sitelik > <NUM_LIT:0>).all(), "<STR_LIT>".format(<EOL>sitelik, self.underflowlogscale)<EOL>self.siteloglik = scipy.log(sitelik) + self.underflowlogscale<EOL>self.loglik = scipy.sum(self.siteloglik) + self.model.logprior<EOL>if self.dparamscurrent:<EOL><INDENT>self._dloglik = {}<EOL>for param in self.model.freeparams:<EOL><INDENT>if self._distributionmodel and (param in<EOL>self.model.distributionparams):<EOL><INDENT>name = self.model.distributedparam<EOL>weighted_dk = (self.model.d_distributionparams[param]<EOL>* catweights)<EOL><DEDENT>else:<EOL><INDENT>name = param<EOL>weighted_dk = catweights<EOL><DEDENT>dsiteloglik = <NUM_LIT:0><EOL>for k in self._catindices:<EOL><INDENT>dsiteloglik += (scipy.sum(<EOL>self._dstationarystate(k, name) *<EOL>self.L[rootnode][k] + self.dL[name][rootnode][k] *<EOL>self._stationarystate(k), axis=-<NUM_LIT:1>) *<EOL>weighted_dk[k])<EOL><DEDENT>dsiteloglik /= sitelik<EOL>self._dloglik[param] = (scipy.sum(dsiteloglik, axis=-<NUM_LIT:1>)<EOL>+ self.model.dlogprior(param))<EOL><DEDENT><DEDENT>if self.dtcurrent:<EOL><INDENT>self._dloglik_dt = <NUM_LIT:0><EOL>dLnroot_dt = scipy.array([self.dL_dt[n2][rootnode] for<EOL>n2 in sorted(self.dL_dt.keys())])<EOL>for k in self._catindices:<EOL><INDENT>if isinstance(k, int):<EOL><INDENT>dLnrootk_dt = dLnroot_dt.swapaxes(<NUM_LIT:0>, <NUM_LIT:1>)[k]<EOL><DEDENT>else:<EOL><INDENT>assert k == slice(None)<EOL>dLnrootk_dt = dLnroot_dt<EOL><DEDENT>self._dloglik_dt += catweights[k] * scipy.sum(<EOL>self._stationarystate(k) *<EOL>dLnrootk_dt, axis=-<NUM_LIT:1>)<EOL><DEDENT>self._dloglik_dt /= sitelik<EOL>self._dloglik_dt = scipy.sum(self._dloglik_dt, axis=-<NUM_LIT:1>)<EOL>assert self._dloglik_dt.shape == self.t.shape<EOL><DEDENT><DEDENT>
Update internal attributes related to likelihood.

        Should be called any time branch lengths or model parameters
        are changed.