def check_ExpCM_derivatives(self):
<EOL>def funcPrxy(paramvalue, paramname, expcm, r, x, y):<EOL><INDENT>if len(paramvalue) == <NUM_LIT:1>:<EOL><INDENT>expcm.updateParams({paramname:paramvalue[<NUM_LIT:0>]})<EOL><DEDENT>else:<EOL><INDENT>expcm.updateParams({paramname:paramvalue})<EOL><DEDENT>return expcm.Prxy[r][x][y]<EOL><DEDENT>def funcdPrxy(paramvalue, paramname, expcm, r, x, y):<EOL><INDENT>if len(paramvalue) == <NUM_LIT:1>:<EOL><INDENT>expcm.updateParams({paramname:paramvalue[<NUM_LIT:0>]})<EOL><DEDENT>else:<EOL><INDENT>expcm.updateParams({paramname:paramvalue})<EOL><DEDENT>return expcm.dPrxy[paramname][r][x][y]<EOL><DEDENT>for (pname, pvalue) in sorted(self.params.items())[::-<NUM_LIT:1>]:<EOL><INDENT>if pname == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>if isinstance(pvalue, float):<EOL><INDENT>pvalue = [pvalue]<EOL><DEDENT>for r in random.sample(range(self.nsites), <NUM_LIT:2>): <EOL><INDENT>for x in random.sample(range(N_CODON), <NUM_LIT:3>): <EOL><INDENT>for y in range(N_CODON):<EOL><INDENT>diff = scipy.optimize.check_grad(funcPrxy, funcdPrxy,<EOL>pvalue, pname, self.expcm_divpressure, r, x, y, epsilon=<NUM_LIT>)<EOL>self.assertTrue(diff < <NUM_LIT>, ("<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>"<EOL>).format(diff, pname, r, x, y,<EOL>self.params['<STR_LIT>'], self.expcm_divpressure.pi_codon[r][x],<EOL>self.expcm_divpressure.pi_codon[r][y], self.expcm_divpressure.mu,<EOL>self.expcm_divpressure.omega, self.expcm_divpressure.Frxy[r][x][y],<EOL>self.expcm_divpressure.Prxy[r][x][y], self.expcm_divpressure.phi,<EOL>self.expcm_divpressure.kappa, self.expcm_divpressure.dQxy_dbeta[x][y],<EOL>self.expcm_divpressure.dphi_dbeta,<EOL>self.expcm_divpressure.dPrxy['<STR_LIT>'][r][x][y],<EOL>self.expcm_divpressure.piAx_piAy_beta[r][x][y]))<EOL><DEDENT><DEDENT><DEDENT>self.expcm_divpressure.updateParams(self.params)<EOL><DEDENT>
Makes sure derivatives are as expected.