Skip to content
Snippets Groups Projects
Commit 38cc1332 authored by MoritzThomasHuebner's avatar MoritzThomasHuebner
Browse files

Added some more tests for 100 % coverage.

Refactored some old tests to make them separate and test one feature at a time
parent 06261851
No related branches found
No related tags found
No related merge requests found
......@@ -211,18 +211,51 @@ class TestStudentTLikelihood(unittest.TestCase):
likelihood.log_likelihood()
self.assertEqual(likelihood.sigma, self.sigma)
def test_unknown_float_nu(self):
def test_set_nu_none(self):
likelihood = tupak.core.likelihood.StudentTLikelihood(
self.x, self.y, self.function, nu=None)
likelihood.parameters['m'] = 2
likelihood.parameters['c'] = 0
self.assertTrue(likelihood.nu is None)
with self.assertRaises((TypeError, ValueError)):
def test_log_likelihood_nu_none(self):
likelihood = tupak.core.likelihood.StudentTLikelihood(
self.x, self.y, self.function, nu=None)
likelihood.parameters['m'] = 2
likelihood.parameters['c'] = 0
with self.assertRaises(TypeError):
likelihood.log_likelihood()
def test_log_likelihood_nu_zero(self):
likelihood = tupak.core.likelihood.StudentTLikelihood(
self.x, self.y, self.function, nu=0)
likelihood.parameters['m'] = 2
likelihood.parameters['c'] = 0
with self.assertRaises(ValueError):
likelihood.log_likelihood()
def test_log_likelihood_nu_negative(self):
likelihood = tupak.core.likelihood.StudentTLikelihood(
self.x, self.y, self.function, nu=-1)
likelihood.parameters['m'] = 2
likelihood.parameters['c'] = 0
with self.assertRaises(ValueError):
likelihood.log_likelihood()
def test_setting_nu_positive_does_not_change_class_attribute(self):
likelihood = tupak.core.likelihood.StudentTLikelihood(
self.x, self.y, self.function, nu=None)
likelihood.parameters['m'] = 2
likelihood.parameters['c'] = 0
likelihood.parameters['nu'] = 98
likelihood.log_likelihood()
self.assertTrue(likelihood.nu is None)
def test_lam(self):
likelihood = tupak.core.likelihood.StudentTLikelihood(
self.x, self.y, self.function, nu=0, sigma=0.5)
self.assertAlmostEqual(4.0, likelihood.lam)
class TestPoissonLikelihood(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment