def test_addbasic_true(self):
     model, options, parameters, data, covariance, rejected, chain, s2chain, sschain = gf.setup_mcmc_case_dr(
     )
     RS = ResultsStructure()
     RS.add_basic(nsimu=options.nsimu,
                  covariance=covariance,
                  parameters=parameters,
                  rejected=rejected,
                  simutime=0.001,
                  theta=chain[-1, :])
     self.assertTrue(RS.basic,
                     msg='basic features added to result structure')
     self.assertTrue(np.array_equal(RS.results['theta'], np.array([0, 0])),
                     msg='Last elements of chain are zero')
 def test_addbasic_rejection(self):
     model, options, parameters, data, covariance, rejected, chain, s2chain, sschain = gf.setup_mcmc_case_dr(
     )
     RS = ResultsStructure()
     RS.add_basic(nsimu=options.nsimu,
                  covariance=covariance,
                  parameters=parameters,
                  rejected=rejected,
                  simutime=0.001,
                  theta=chain[-1, :])
     self.assertEqual(RS.results['total_rejected'],
                      10 * (options.nsimu**(-1)),
                      msg='rejection reported as fraction of nsimu')
     self.assertEqual(RS.results['rejected_outside_bounds'],
                      2 * (options.nsimu**(-1)),
                      msg='rejection reported as fraction of nsimu')
 def test_addbasic_covariance(self):
     model, options, parameters, data, covariance, rejected, chain, s2chain, sschain = gf.setup_mcmc_case_dr(
     )
     covariance._R[0, 0] = 1.1
     covariance._R[0, 1] = 2.3
     RS = ResultsStructure()
     RS.add_basic(nsimu=options.nsimu,
                  covariance=covariance,
                  parameters=parameters,
                  rejected=rejected,
                  simutime=0.001,
                  theta=chain[-1, :])
     self.assertTrue(np.array_equal(RS.results['R'], covariance._R),
                     msg='Cholesky matches')
     self.assertTrue(np.array_equal(
         RS.results['qcov'], np.dot(covariance._R.transpose(),
                                    covariance._R)),
                     msg='Covariance matches')
 def test_allnames(self):
     model, options, parameters, data, covariance, rejected, chain, s2chain, sschain = gf.setup_mcmc_case_dr(
     )
     RS = ResultsStructure()
     RS.add_basic(nsimu=options.nsimu,
                  covariance=covariance,
                  parameters=parameters,
                  rejected=rejected,
                  simutime=0.001,
                  theta=chain[-1, :])
     allnames = RS.results['allnames']
     names = RS.results['names']
     print(allnames)
     print(names)
     self.assertEqual(len(allnames),
                      len(names) + 1,
                      msg='Expect extra name in allnames')
     self.assertEqual(allnames[-1],
                      'b2',
                      msg='Expect final parameter is b2')
 def test_addbasic_true(self):
     model, options, parameters, data, covariance, rejected, chain, s2chain, sschain = gf.setup_mcmc_case_dr(
     )
     covariance._RDR = np.random.random_sample(size=(2, 2))
     DR = DelayedRejection()
     DR._initialize_dr_metrics(options)
     DR.dr_step_counter = 12000
     RS = ResultsStructure()
     RS.add_basic(nsimu=options.nsimu,
                  covariance=covariance,
                  parameters=parameters,
                  rejected=rejected,
                  simutime=0.001,
                  theta=chain[-1, :])
     self.assertTrue(RS.add_dram(drscale=options.drscale,
                                 RDR=covariance._RDR,
                                 total_rejected=rejected['total'],
                                 drsettings=DR),
                     msg='basic features added to result structure')
     self.assertTrue(np.array_equal(RS.results['RDR'], covariance._RDR),
                     msg='RDR matches')
     self.assertEqual(RS.results['alpha_count'],
                      DR.dr_step_counter,
                      msg='Alpha count matches dr step counter')