def check_YNGKP_M0_derivatives(self):
<EOL>def funcPxy(paramvalue, paramname, YNGKP_M0, x, y):<EOL><INDENT>if len(paramvalue) == <NUM_LIT:1>:<EOL><INDENT>YNGKP_M0.updateParams({paramname:paramvalue[<NUM_LIT:0>]})<EOL><DEDENT>else:<EOL><INDENT>YNGKP_M0.updateParams({paramname:paramvalue})<EOL><DEDENT>return YNGKP_M0.Pxy[<NUM_LIT:0>][x][y]<EOL><DEDENT>def funcdPxy(paramvalue, paramname, YNGKP_M0, x, y):<EOL><INDENT>if len(paramvalue) == <NUM_LIT:1>:<EOL><INDENT>YNGKP_M0.updateParams({paramname:paramvalue[<NUM_LIT:0>]})<EOL><DEDENT>else:<EOL><INDENT>YNGKP_M0.updateParams({paramname:paramvalue})<EOL><DEDENT>return YNGKP_M0.dPxy[paramname][<NUM_LIT:0>][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 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(funcPxy, funcdPxy,<EOL>pvalue, pname, self.YNGKP_M0, 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>).format(diff, pname, x, y,<EOL>self.YNGKP_M0.mu, self.YNGKP_M0.omega,<EOL>self.YNGKP_M0.Pxy[<NUM_LIT:0>][x][y],<EOL>self.YNGKP_M0.kappa))<EOL><DEDENT><DEDENT>self.YNGKP_M0.updateParams(self.params)<EOL><DEDENT>
Makes sure derivatives are as expected.