def dM(self, t, param, Mt, tips=None, gaps=None):
assert isinstance(t, float) and t > <NUM_LIT:0>, "<STR_LIT>".format(t)<EOL>assert (param == '<STR_LIT:t>') or (param in self.freeparams), (<EOL>"<STR_LIT>".format(param))<EOL>if Mt is None:<EOL><INDENT>Mt = self.M(t, tips=tips, gaps=gaps)<EOL><DEDENT>if (param == '<STR_LIT>') or (param == '<STR_LIT:t>'):<EOL><INDENT>if param == '<STR_LIT>':<EOL><INDENT>alpha = t<EOL><DEDENT>else:<EOL><INDENT>alpha = self.mu<EOL><DEDENT>if tips is None:<EOL><INDENT>dM_param = scipy.tile(broadcastMatrixMultiply(self.Pxy,<EOL>scipy.tile(Mt[<NUM_LIT:0>], (<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>)), alpha=alpha),<EOL>(self.nsites, <NUM_LIT:1>, <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>dM_param = broadcastMatrixVectorMultiply(scipy.tile(self.Pxy[<NUM_LIT:0>],<EOL>(self.nsites, <NUM_LIT:1>, <NUM_LIT:1>)), Mt, alpha=alpha)<EOL>if gaps is not None:<EOL><INDENT>dM_param[gaps] = scipy.zeros(N_CODON, dtype='<STR_LIT:float>')<EOL><DEDENT><DEDENT>return dM_param<EOL><DEDENT>paramval = getattr(self, param)<EOL>assert isinstance(paramval, float), "<STR_LIT>"<EOL>if ('<STR_LIT>', t) not in self._cached:<EOL><INDENT>self._cached[('<STR_LIT>', t)] = scipy.exp(self.D * self.mu * t)<EOL><DEDENT>expD = self._cached[('<STR_LIT>', t)]<EOL>if ('<STR_LIT>', t) not in self._cached:<EOL><INDENT>if '<STR_LIT>' not in self._cached:<EOL><INDENT>Dyy = scipy.tile(self.D, (<NUM_LIT:1>, N_CODON)).reshape(<EOL><NUM_LIT:1>, N_CODON, N_CODON)<EOL>Dxx = scipy.array([Dyy[r].transpose() for r in<EOL>range(<NUM_LIT:1>)])<EOL>self._cached['<STR_LIT>'] = Dxx - Dyy<EOL><DEDENT>Dxx_Dyy = self._cached['<STR_LIT>']<EOL>if '<STR_LIT>' not in self._cached:<EOL><INDENT>self._cached['<STR_LIT>'] = scipy.fabs(<EOL>Dxx_Dyy) < ALMOST_ZERO<EOL><DEDENT>Dxx_Dyy_lt_ALMOST_ZERO = self._cached['<STR_LIT>']<EOL>with scipy.errstate(divide='<STR_LIT>', under='<STR_LIT:ignore>',<EOL>over='<STR_LIT>', invalid='<STR_LIT:ignore>'):<EOL><INDENT>expDyy = scipy.tile(expD, (<NUM_LIT:1>, N_CODON)).reshape(<EOL><NUM_LIT:1>, N_CODON, N_CODON)<EOL>expDxx = scipy.array([expDyy[r].transpose() for r in<EOL>range(<NUM_LIT:1>)])<EOL>V = (expDxx - expDyy) / Dxx_Dyy<EOL><DEDENT>with scipy.errstate(under='<STR_LIT:ignore>'): <EOL><INDENT>scipy.copyto(V, self.mu * t * expDxx, where=<EOL>Dxx_Dyy_lt_ALMOST_ZERO)<EOL><DEDENT>self._cached[('<STR_LIT>', t)] = V<EOL><DEDENT>V = self._cached[('<STR_LIT>', t)]<EOL>with scipy.errstate(under='<STR_LIT:ignore>'): <EOL><INDENT>dM_param = broadcastMatrixMultiply(self.A,<EOL>broadcastMatrixMultiply(self.B[param]<EOL>* V, self.Ainv))<EOL>if tips is None:<EOL><INDENT>return scipy.tile(dM_param, (self.nsites, <NUM_LIT:1>, <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>newdM_param = scipy.zeros((len(tips), N_CODON))<EOL>for i in range(len(tips)):<EOL><INDENT>newdM_param[i] =(dM_param[<NUM_LIT:0>][:,tips[i]])<EOL><DEDENT>if gaps is not None:<EOL><INDENT>newdM_param[gaps] = scipy.zeros(N_CODON, dtype='<STR_LIT:float>')<EOL><DEDENT>return newdM_param<EOL><DEDENT><DEDENT>
See docs for method in `Model` abstract base class.