mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-18 13:55:14 +02:00
Merge branch 'devel' of github.com:SheffieldML/GPy into devel
This commit is contained in:
commit
05afd8eb7b
5 changed files with 83 additions and 10 deletions
|
|
@ -6,6 +6,29 @@ import numpy as np
|
|||
import GPy
|
||||
|
||||
class PriorTests(unittest.TestCase):
|
||||
def test_studentT(self):
|
||||
xmin, xmax = 1, 2.5*np.pi
|
||||
b, C, SNR = 1, 0, 0.1
|
||||
X = np.linspace(xmin, xmax, 500)
|
||||
y = b*X + C + 1*np.sin(X)
|
||||
y += 0.05*np.random.randn(len(X))
|
||||
X, y = X[:, None], y[:, None]
|
||||
studentT = GPy.priors.StudentT(1, 2, 4)
|
||||
|
||||
m = GPy.models.SparseGPRegression(X, y)
|
||||
m.Z.set_prior(studentT)
|
||||
|
||||
# setting a StudentT prior on non-negative parameters
|
||||
# should raise an assertionerror.
|
||||
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
|
||||
b, C, SNR = 1, 0, 0.1
|
||||
|
|
@ -74,7 +97,7 @@ class PriorTests(unittest.TestCase):
|
|||
# setting a Gaussian prior on non-negative parameters
|
||||
# should raise an assertionerror.
|
||||
#self.assertRaises(AssertionError, m.Z.set_prior, gaussian)
|
||||
|
||||
self.assertTrue(m.checkgrad())
|
||||
|
||||
|
||||
def test_fixed_domain_check(self):
|
||||
|
|
@ -107,8 +130,6 @@ class PriorTests(unittest.TestCase):
|
|||
# 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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue