Ejemplo n.º 1
0
 def test_get_priors_log_prob (self):
     """ Given theta, we should be able to get
         log {p(theta)}. """
     priors_file = 'input/kolch_model.priors'  
     theta = read_priors_file (priors_file)
     # theta has been randomly generated by the joint distribution,
     # and there's a high (but of course not 1) probability of the
     # log of the pdf being representable in floating point (it 
     # could not be if the value is really small).
     log_prior = theta.get_log_p ()
     assert (not self.is_nan (log_prior))
     assert (log_prior > float ('-inf'))
Ejemplo n.º 2
0
 def test_read_lognormal(self):
     """ Tests if the module can correctly read a prior definition 
         file. """
     priors = read_priors_file('input/lognormal.priors')
     for x in priors:
         distribution = x.get_distribution()
         if x.name == 'k1':
             expected_mean = np.exp(3)
             self.assertEqual(distribution.mean(), expected_mean)
         elif x.name == 'd1':
             expected_mean = np.exp(10)
             self.assertEqual(distribution.mean(), expected_mean)
         elif x.name == "Sigma" or x.name == "Noise":
             pass
         else:
             self.fail()
Ejemplo n.º 3
0
 def test_reader(self):
     """ Tests if the module can correctly read a prior definition 
         file. """
     priors = read_priors_file('input/simple_enzymatic.priors')
     for x in priors:
         distribution = x.get_distribution()
         if x.name == 'k1':
             self.assertEqual(distribution.get_a(), 2.0)
             self.assertEqual(distribution.get_b(), 0.01)
         elif x.name == 'd1' or x.name == 'kcat':
             self.assertEqual(distribution.get_a(), 2.0)
             self.assertEqual(distribution.get_b(), 0.1)
         elif x.name == "Noise":
             pass
         else:
             self.fail()
Ejemplo n.º 4
0
 def test_write_priors(self):
     """ Tests if it is possible to write a priors file. """
     priors = read_priors_file('input/simple_enzymatic.priors')
     write_priors_file('input/simple_enzymatic_out.priors', priors)
     assert (filecmp.cmp ('input/simple_enzymatic_out.priors', \
             'input/simple_enzymatic.priors'))
Ejemplo n.º 5
0
 def test_sigma_prior(self):
     """ Tests if the module can read the experimental error 
         prior. """
     priors = read_priors_file('input/simple_enzymatic.priors')
     sigma = priors.get_experimental_error()
     assert (sigma > 0)