a cleaner test

This commit is contained in:
Daniel Beck 2015-02-09 09:41:21 +11:00
parent d6a56a6f0b
commit fc8705104b
2 changed files with 3 additions and 6 deletions

View file

@ -61,7 +61,6 @@ class Prod(CombinationKernel):
for p in self.parts:
p.update_gradients_full(k/p.K(X,X2),X,X2)
except FloatingPointError:
#print "WARNING: gradient calculation falling back to slow version due to zero-valued kernel"
for combination in itertools.combinations(self.parts, len(self.parts) - 1):
prod = reduce(np.multiply, [p.K(X, X2) for p in combination])
to_update = list(set(self.parts) - set(combination))[0]

View file

@ -408,11 +408,9 @@ class KernelTestsProductWithZeroValues(unittest.TestCase):
lin = GPy.kern.Linear(2)
bias = GPy.kern.Bias(2)
k = lin * bias
m = GPy.models.GPRegression(X, Y, kernel=k)
try:
m.optimize()
except np.linalg.LinAlgError:
self.fail("Zero-valued kernel raised exception!")
k.update_gradients_full(1, X)
self.assertFalse(np.isnan(k['linear.variances'].gradient),
"Gradient resulted in NaN")