regular expressions now match rather than search

This commit is contained in:
James Hensman 2013-06-04 14:36:17 +01:00
parent 26b4cd6c4f
commit aa8b75d0c5
5 changed files with 42 additions and 47 deletions

View file

@ -8,7 +8,7 @@ import GPy
class KernelTests(unittest.TestCase):
def test_kerneltie(self):
K = GPy.kern.rbf(5, ARD=True)
K.tie_params('[01]')
K.tie_params('.*[01]')
K.constrain_fixed('2')
X = np.random.rand(5,5)
Y = np.ones((5,1))

View file

@ -22,7 +22,7 @@ class GradientTests(unittest.TestCase):
self.X2D = np.random.uniform(-3.,3.,(40,2))
self.Y2D = np.sin(self.X2D[:,0:1]) * np.sin(self.X2D[:,1:2])+np.random.randn(40,1)*0.05
def check_model_with_white(self, kern, model_type='GP_regression', dimension=1, constraint=''):
def check_model_with_white(self, kern, model_type='GP_regression', dimension=1):
#Get the correct gradients
if dimension == 1:
X = self.X1D
@ -37,7 +37,7 @@ class GradientTests(unittest.TestCase):
noise = GPy.kern.white(dimension)
kern = kern + noise
m = model_fit(X, Y, kernel=kern)
m.constrain_positive(constraint)
m.ensure_default_constraints()
m.randomize()
# contrain all parameters to be positive
self.assertTrue(m.checkgrad())
@ -135,12 +135,12 @@ class GradientTests(unittest.TestCase):
def test_sparse_GP_regression_rbf_white_kern_1d(self):
''' Testing the sparse GP regression with rbf kernel with white kernel on 1d data '''
rbf = GPy.kern.rbf(1)
self.check_model_with_white(rbf, model_type='sparse_GP_regression', dimension=1, constraint='(variance|lengthscale|precision)')
self.check_model_with_white(rbf, model_type='sparse_GP_regression', dimension=1)
def test_sparse_GP_regression_rbf_white_kern_2D(self):
''' Testing the sparse GP regression with rbf and white kernel on 2d data '''
rbf = GPy.kern.rbf(2)
self.check_model_with_white(rbf, model_type='sparse_GP_regression', dimension=2, constraint='(variance|lengthscale|precision)')
self.check_model_with_white(rbf, model_type='sparse_GP_regression', dimension=2)
def test_GPLVM_rbf_bias_white_kern_2D(self):
""" Testing GPLVM with rbf + bias and white kernel """
@ -150,7 +150,7 @@ class GradientTests(unittest.TestCase):
K = k.K(X)
Y = np.random.multivariate_normal(np.zeros(N),K,D).T
m = GPy.models.GPLVM(Y, Q, kernel = k)
m.constrain_positive('(rbf|bias|white)')
m.ensure_default_constraints()
self.assertTrue(m.checkgrad())
def test_GPLVM_rbf_linear_white_kern_2D(self):
@ -161,7 +161,7 @@ class GradientTests(unittest.TestCase):
K = k.K(X)
Y = np.random.multivariate_normal(np.zeros(N),K,D).T
m = GPy.models.GPLVM(Y, Q, init = 'PCA', kernel = k)
m.constrain_positive('(linear|bias|white)')
m.ensure_default_constraints()
self.assertTrue(m.checkgrad())
def test_GP_EP_probit(self):