From 375f3e0d6c7ee2656f964ba1ad70e03e1cb4aba8 Mon Sep 17 00:00:00 2001 From: mzwiessele Date: Wed, 11 May 2016 15:02:44 +0100 Subject: [PATCH] [setxy] was bugged --- GPy/core/gp.py | 8 +++++--- GPy/testing/gp_tests.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GPy/core/gp.py b/GPy/core/gp.py index 1434573a..decca6b8 100644 --- a/GPy/core/gp.py +++ b/GPy/core/gp.py @@ -148,14 +148,16 @@ class GP(Model): # LVM models if isinstance(self.X, VariationalPosterior): assert isinstance(X, type(self.X)), "The given X must have the same type as the X in the model!" + index = self.X._parent_index_ self.unlink_parameter(self.X) self.X = X - self.link_parameter(self.X) + self.link_parameter(self.X, index=index) else: + index = self.X._parent_index_ self.unlink_parameter(self.X) from ..core import Param - self.X = Param('latent mean',X) - self.link_parameter(self.X) + self.X = Param('latent mean', X) + self.link_parameter(self.X, index=index) else: self.X = ObsAr(X) self.update_model(True) diff --git a/GPy/testing/gp_tests.py b/GPy/testing/gp_tests.py index 3ce3ffc4..97e3718d 100644 --- a/GPy/testing/gp_tests.py +++ b/GPy/testing/gp_tests.py @@ -24,9 +24,9 @@ class Test(unittest.TestCase): k = GPy.kern.RBF(1) m = GPy.models.BayesianGPLVM(self.Y, 1, kernel=k) mu, var = m.predict(m.X) - X = m.X.copy() + X = m.X Xnew = NormalPosterior(m.X.mean[:10].copy(), m.X.variance[:10].copy()) - m.set_XY(Xnew, m.Y[:10]) + m.set_XY(Xnew, m.Y[:10].copy()) assert(m.checkgrad()) m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X) @@ -40,7 +40,7 @@ class Test(unittest.TestCase): mu, var = m.predict(m.X) X = m.X.copy() Xnew = X[:10].copy() - m.set_XY(Xnew, m.Y[:10]) + m.set_XY(Xnew, m.Y[:10].copy()) assert(m.checkgrad()) m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X)