diff --git a/GPy/core/gp.py b/GPy/core/gp.py index 1e2e3611..d8f1e758 100644 --- a/GPy/core/gp.py +++ b/GPy/core/gp.py @@ -235,6 +235,8 @@ class GP(Model): self.link_parameter(self.X, index=index) else: self.X = ObsAr(X) + + self.num_data, self.input_dim = self.X.shape self.update_model(True) def set_X(self,X): @@ -587,9 +589,9 @@ class GP(Model): :param size: the number of a posteriori samples. :type size: int. :returns: set of simulations - :rtype: np.ndarray (Nnew x D x samples) + :rtype: np.ndarray (Nnew x D x samples) """ - predict_kwargs["full_cov"] = True # Always use the full covariance for posterior samples. + predict_kwargs["full_cov"] = True # Always use the full covariance for posterior samples. m, v = self._raw_predict(X, **predict_kwargs) if self.normalizer is not None: m, v = self.normalizer.inverse_mean(m), self.normalizer.inverse_variance(v) diff --git a/GPy/testing/gp_tests.py b/GPy/testing/gp_tests.py index 97e3718d..1f44304d 100644 --- a/GPy/testing/gp_tests.py +++ b/GPy/testing/gp_tests.py @@ -28,11 +28,14 @@ class Test(unittest.TestCase): Xnew = NormalPosterior(m.X.mean[:10].copy(), m.X.variance[:10].copy()) m.set_XY(Xnew, m.Y[:10].copy()) assert(m.checkgrad()) + + assert(m.num_data == m.X.shape[0]) + assert(m.input_dim == m.X.shape[1]) + m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X) np.testing.assert_allclose(mu, mu2) np.testing.assert_allclose(var, var2) - def test_setxy_gplvm(self): k = GPy.kern.RBF(1) @@ -42,6 +45,10 @@ class Test(unittest.TestCase): Xnew = X[:10].copy() m.set_XY(Xnew, m.Y[:10].copy()) assert(m.checkgrad()) + + assert(m.num_data == m.X.shape[0]) + assert(m.input_dim == m.X.shape[1]) + m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X) np.testing.assert_allclose(mu, mu2) @@ -54,6 +61,10 @@ class Test(unittest.TestCase): X = m.X.copy() m.set_XY(m.X[:10], m.Y[:10]) assert(m.checkgrad()) + + assert(m.num_data == m.X.shape[0]) + assert(m.input_dim == m.X.shape[1]) + m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X) np.testing.assert_allclose(mu, mu2)