diff --git a/GPy/testing/prior_tests.py b/GPy/testing/prior_tests.py index 269d8b2d0..23822a5a1 100644 --- a/GPy/testing/prior_tests.py +++ b/GPy/testing/prior_tests.py @@ -13,20 +13,21 @@ def test_studentT(self): y = b*X + C + 1*np.sin(X) y += 0.05*np.random.randn(len(X)) X, y = X[:, None], y[:, None] - m = GPy.models.GPRegression(X, y) studentT = GPy.priors.StudentT(1, 2, 4) - # setting a StudentT prior on non-negative parameters - # should raise an assertionerror. - self.assertRaises(AssertionError, m.rbf.set_prior, studentT) m = GPy.models.SparseGPRegression(X, y) - - gaussian = GPy.priors.Gaussian(1, 1) m.Z.set_prior(studentT) - # setting a Gaussian prior on non-negative parameters + + # setting a StudentT prior on non-negative parameters # should raise an assertionerror. - #self.assertRaises(AssertionError, m.Z.set_prior, gaussian) + self.assertRaises(AssertionError, m.rbf.set_prior, studentT) + + # The gradients need to be checked self.assertTrue(m.checkgrad()) + + # Check the singleton pattern: + self.assertIs(studentT, GPy.priors.StudentT(1,2,4)) + self.assertIsNot(studentT, GPy.priors.StudentT(2,2,4)) def test_lognormal(self): xmin, xmax = 1, 2.5*np.pi @@ -129,7 +130,6 @@ def test_fixed_domain_check1(self): # should raise an assertionerror. self.assertRaises(AssertionError, m.rbf.set_prior, gaussian) - if __name__ == "__main__": print("Running unit tests, please be (very) patient...") unittest.main()