def test_get_values (self):
     """ Tests if we can get only the values of the parameters. """
     p1 = RandomParameter ('p1', Gamma (2, 2))
     p2 = RandomParameter ('p2', Gamma (3, 2))
     p1.value = 1
     p2.value = 2
     theta = RandomParameterList ()
     theta.append (p1)
     theta.append (p2)
     values = theta.get_values ()
     self.assertEqual (values[0], 1)
     self.assertEqual (values[1], 2)
Exemple #2
0
    def test_manual_jump (self):
        """ Tests if one can perform a manual jump. """
        n = 10
        theta = RandomParameterList ()
        for i in range (n):
            gamma = Gamma (2, 2)
            rand_par = RandomParameter ('p', gamma)
            theta.append (rand_par)
        
        mocked_mh = MHLikelihoodMock (theta)
        mocked_mh.start_sample_from_prior ()
        mocked_mh.manual_jump (theta, 1)

        sample = mocked_mh.get_last_sampled (2)[0]
        last_theta = sample[-1]
        theta_vals = np.array (theta.get_values ())
        last_theta_vals = np.array (last_theta.get_values ())
        assert all (theta_vals == last_theta_vals)