def test_update_cov(self):
        __, options, parameters, __ = gf.setup_mcmc()
        CP = CovarianceProcedures()
        CP._initialize_covariance_settings(parameters=parameters,
                                           options=options)
        check = {
            'R': np.random.random_sample(size=(2, 2)),
            'covchain': np.random.random_sample(size=(2, 2)),
            'meanchain': np.random.random_sample(size=(1, 2)),
            'wsum': np.random.random_sample(size=(2, 1)),
            'last_index_since_adaptation': 0,
            'iiadapt': 100
        }
        CP._update_covariance_from_adaptation(**check)
        CPD = CP.__dict__
        items = ['last_index_since_adaptation', 'iiadapt']
        for __, ai in enumerate(items):
            self.assertEqual(CPD[str('_{}'.format(ai))],
                             check[ai],
                             msg=str('{}: {} != {}'.format(
                                 ai, CPD[str('_{}'.format(ai))], check[ai])))

        array_items = ['R', 'covchain', 'meanchain', 'wsum']
        for __, ai in enumerate(array_items):
            self.assertTrue(np.array_equal(CPD[str('_{}'.format(ai))],
                                           check[ai]),
                            msg=str('{}: {} != {}'.format(
                                ai, CPD[str('_{}'.format(ai))], check[ai])))
 def test_init_CP_original_cov(self):
     CP = CovarianceProcedures()
     __, options, parameters, __ = gf.setup_mcmc()
     CP = CovarianceProcedures()
     CP._initialize_covariance_settings(parameters=parameters,
                                        options=options)
     self.assertTrue(hasattr(CP, '_qcov_original'),
                     msg='Has assigned original covariance matrix')
     original_covariance = CP._qcov_original.copy()
     check = {
         'R': np.random.random_sample(size=(2, 2)),
         'covchain': np.random.random_sample(size=(2, 2)),
         'meanchain': np.random.random_sample(size=(1, 2)),
         'wsum': np.random.random_sample(size=(2, 1)),
         'last_index_since_adaptation': 0,
         'iiadapt': 100
     }
     CP._update_covariance_from_adaptation(**check)
     self.assertTrue(
         np.array_equal(CP._qcov_original, original_covariance),
         msg='Expect original cov. mtx. unchanged after update.')