def t_basicfit(self, yfac, pfac, p0file):
ycov = np.array([[<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>]]) * yfac<EOL>y = gv.gvar([<NUM_LIT:1.>, <NUM_LIT>], ycov)<EOL>pr = gv.BufferDict()<EOL>pcov = np.array([[<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT:1.>]]) * pfac<EOL>pr['<STR_LIT:p>'] = gv.gvar([<NUM_LIT>, <NUM_LIT>], pcov)<EOL>def fcn(x,p):<EOL><INDENT>return dict(y=p['<STR_LIT:p>'] ** <NUM_LIT:2>)<EOL><DEDENT>y = dict(y=y)<EOL>fit = nonlinear_fit(data=(None,y), prior=pr, fcn=fcn, p0=p0file, debug=True)<EOL>with open(p0file, '<STR_LIT:rb>') as f:<EOL><INDENT>p0 = pickle.load(f)<EOL>self.assert_arraysclose(p0['<STR_LIT:p>'], fit.pmean['<STR_LIT:p>'])<EOL><DEDENT>print_fit(fit,dict(y=wavg(fit.p['<STR_LIT:p>']**<NUM_LIT:2>)))<EOL>self.assertEqual(fit.dof, <NUM_LIT:2>)<EOL>self.assertAlmostEqual(fit.Q, <NUM_LIT:1.0>)<EOL>self.assertAlmostEqual(fit.chi2, <NUM_LIT:0.0>)<EOL>cd = {'<STR_LIT:data>':fit.y, '<STR_LIT>':fit.prior, '<STR_LIT:p>':[fit.prior['<STR_LIT:p>']]}<EOL>err = {}<EOL>err['<STR_LIT:data>'] = fit.p['<STR_LIT:p>'][<NUM_LIT:1>].partialsdev(fit.y)<EOL>err['<STR_LIT>'] = fit.p['<STR_LIT:p>'][<NUM_LIT:1>].partialsdev(fit.prior)<EOL>err['<STR_LIT:p>'] = fit.p['<STR_LIT:p>'][<NUM_LIT:1>].partialsdev(fit.prior['<STR_LIT:p>'])<EOL>if yfac><NUM_LIT:100>*pfac:<EOL><INDENT>self.assert_gvclose(fit.p,pr)<EOL>self.assert_arraysclose(fit.pmean['<STR_LIT:p>'], gv.mean(pr)['<STR_LIT:p>'])<EOL>self.assert_arraysclose(fit.psdev['<STR_LIT:p>'], gv.sdev(pr)['<STR_LIT:p>'])<EOL>self.assert_arraysclose(pcov,fit.cov)<EOL>self.assert_arraysclose(pcov,gv.evalcov(fit.p['<STR_LIT:p>']))<EOL>self.assertNotAlmostEqual(fit.p['<STR_LIT:p>'][<NUM_LIT:1>].sdev,err['<STR_LIT:data>'],<EOL>delta=<NUM_LIT>*err['<STR_LIT>'])<EOL>self.assertAlmostEqual(fit.p['<STR_LIT:p>'][<NUM_LIT:1>].sdev,err['<STR_LIT>'],<EOL>delta=<NUM_LIT>*err['<STR_LIT>'])<EOL>self.assertAlmostEqual(fit.p['<STR_LIT:p>'][<NUM_LIT:1>].sdev,err['<STR_LIT:p>'],<EOL>delta=<NUM_LIT>*err['<STR_LIT:p>'])<EOL><DEDENT>elif pfac><NUM_LIT:100>*yfac:<EOL><INDENT>self.assert_gvclose(fit.p['<STR_LIT:p>']**<NUM_LIT:2>,y['<STR_LIT:y>'])<EOL>self.assert_arraysclose(fit.pmean['<STR_LIT:p>']**<NUM_LIT:2>,[x.mean for x in y['<STR_LIT:y>']])<EOL>self.assert_arraysclose([x.sdev for x in fit.p['<STR_LIT:p>']**<NUM_LIT:2>],<EOL>[x.sdev for x in y['<STR_LIT:y>']])<EOL>self.assert_arraysclose(ycov,gv.evalcov(fit.p['<STR_LIT:p>']**<NUM_LIT:2>))<EOL>self.assertAlmostEqual(fit.p['<STR_LIT:p>'][<NUM_LIT:1>].sdev,err['<STR_LIT:data>'],<EOL>delta=<NUM_LIT>*err['<STR_LIT:data>'])<EOL>self.assertNotAlmostEqual(fit.p['<STR_LIT:p>'][<NUM_LIT:1>].sdev,err['<STR_LIT:p>'],<EOL>delta=<NUM_LIT>*err['<STR_LIT:p>'])<EOL>self.assertNotAlmostEqual(fit.p['<STR_LIT:p>'][<NUM_LIT:1>].sdev,err['<STR_LIT>'],<EOL>delta=<NUM_LIT>*err['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>self.assertTrue(False)<EOL><DEDENT>
checks means, sdevs, fit.cov, etc in extreme cases