Skip to content

Commit

Permalink
[prior] singleton tested
Browse files Browse the repository at this point in the history
  • Loading branch information
mzwiessele committed Aug 25, 2016
1 parent 7b63a19 commit 77b4325
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions GPy/testing/prior_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 77b4325

Please sign in to comment.