diff --git a/.travis.yml b/.travis.yml index 3cf32212..22a7e165 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ install: - pip install pypandoc - pip install git+git://github.com/BRML/climin.git - pip install autograd +- pip install nose-show-skipped - python setup.py develop script: diff --git a/GPy/kern/src/static.py b/GPy/kern/src/static.py index 18f7605f..56e2729a 100644 --- a/GPy/kern/src/static.py +++ b/GPy/kern/src/static.py @@ -85,10 +85,10 @@ class WhiteHeteroscedastic(Static): def __init__(self, input_dim, num_data, variance=1., active_dims=None, name='white_hetero'): """ A heteroscedastic White kernel (nugget/noise). - It defines one variance (nugget) per input sample. - + It defines one variance (nugget) per input sample. + Prediction excludes any noise learnt by this Kernel, so be careful using this kernel. - + You can plot the errors learnt by this kernel by something similar as: plt.errorbar(m.X, m.Y, yerr=2*np.sqrt(m.kern.white.variance)) """ @@ -98,7 +98,7 @@ class WhiteHeteroscedastic(Static): def Kdiag(self, X): if X.shape[0] == self.variance.shape[0]: - # If the input has the same number of samples as + # If the input has the same number of samples as # the number of variances, we return the variances return self.variance return 0. @@ -181,7 +181,7 @@ class Fixed(Static): self.variance.gradient = np.einsum('ij,ij', dL_dK, self.fixed_K) def update_gradients_diag(self, dL_dKdiag, X): - self.variance.gradient = np.einsum('i,i', dL_dKdiag, self.fixed_K) + self.variance.gradient = np.einsum('i,i', dL_dKdiag, np.diagonal(self.fixed_K)) def psi2(self, Z, variational_posterior): return np.zeros((Z.shape[0], Z.shape[0]), dtype=np.float64) diff --git a/GPy/plotting/gpy_plot/data_plots.py b/GPy/plotting/gpy_plot/data_plots.py index 5e6373e5..e806f1e2 100644 --- a/GPy/plotting/gpy_plot/data_plots.py +++ b/GPy/plotting/gpy_plot/data_plots.py @@ -158,7 +158,7 @@ def _plot_data_error(self, canvas, which_data_rows='all', return plots -def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', **plot_kwargs): +def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', legend=True, **plot_kwargs): """ Plot the inducing inputs of a sparse gp model @@ -167,7 +167,7 @@ def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', ** """ canvas, kwargs = pl().new_canvas(projection=projection, **plot_kwargs) plots = _plot_inducing(self, canvas, visible_dims, projection, label, **kwargs) - return pl().add_to_canvas(canvas, plots, legend=label is not None) + return pl().add_to_canvas(canvas, plots, legend=legend) def _plot_inducing(self, canvas, visible_dims, projection, label, **plot_kwargs): if visible_dims is None: diff --git a/GPy/testing/gpy_kernels_state_space_tests.py b/GPy/testing/gpy_kernels_state_space_tests.py index fb5fa228..1dd8dc93 100644 --- a/GPy/testing/gpy_kernels_state_space_tests.py +++ b/GPy/testing/gpy_kernels_state_space_tests.py @@ -97,7 +97,7 @@ class StateSpaceKernelsTests(np.testing.TestCase): ss_kernel = GPy.kern.sde_RBF(1, 110., 1.5, active_dims=[0,]) gp_kernel = GPy.kern.RBF(1, 110., 1.5, active_dims=[0,]) - + self.run_for_model(X, Y, ss_kernel, check_gradients=True, predict_X=X, gp_kernel=gp_kernel, @@ -193,7 +193,7 @@ class StateSpaceKernelsTests(np.testing.TestCase): def test_kernel_addition(self,): #np.random.seed(329) # seed the random number generator - np.random.seed(333) + np.random.seed(42) (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=5.0, noise_var=2.0, plot = False, points_num=100, x_interval = (0, 40), random=True) diff --git a/GPy/testing/kernel_tests.py b/GPy/testing/kernel_tests.py index 6b620406..ae9aebfb 100644 --- a/GPy/testing/kernel_tests.py +++ b/GPy/testing/kernel_tests.py @@ -325,6 +325,14 @@ class KernelGradientTestsContinuous(unittest.TestCase): k.randomize() self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + def test_Fixed(self): + Xall = np.concatenate([self.X, self.X]) + cov = np.dot(Xall, Xall.T) + X = np.arange(self.N).reshape(1,self.N) + k = GPy.kern.Fixed(1, cov) + k.randomize() + self.assertTrue(check_kernel_gradient_functions(k, X=X, X2=None, verbose=verbose)) + def test_Poly(self): k = GPy.kern.Poly(self.D, order=5) k.randomize() diff --git a/GPy/testing/plotting_tests.py b/GPy/testing/plotting_tests.py index 07f4afd2..4922a3ec 100644 --- a/GPy/testing/plotting_tests.py +++ b/GPy/testing/plotting_tests.py @@ -302,7 +302,7 @@ def test_twod(): #m.optimize() m.plot_data() m.plot_mean() - m.plot_inducing() + m.plot_inducing(legend=False, marker='s') #m.plot_errorbars_trainset() m.plot_data_error() for do_test in _image_comparison(baseline_images=['gp_2d_{}'.format(sub) for sub in ["data", "mean", diff --git a/travis_tests.py b/travis_tests.py index 5ad7bace..3c1c5c95 100644 --- a/travis_tests.py +++ b/travis_tests.py @@ -36,5 +36,5 @@ matplotlib.use('agg') import nose, warnings with warnings.catch_warnings(): warnings.simplefilter("ignore") - nose.main('GPy', defaultTest='GPy/testing/', argv=['', '-v']) + nose.main('GPy', defaultTest='GPy/testing/', argv=['', '--show-skipped'])