From 4b427de8fa0ad2276f0cb9593b018965b5d941dc Mon Sep 17 00:00:00 2001 From: Martin Bubel Date: Tue, 10 Oct 2023 20:01:25 +0200 Subject: [PATCH] migrate svgp_tests to pytest --- GPy/testing/svgp_tests.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/GPy/testing/svgp_tests.py b/GPy/testing/svgp_tests.py index 3729d3f0..e6785d42 100644 --- a/GPy/testing/svgp_tests.py +++ b/GPy/testing/svgp_tests.py @@ -2,12 +2,12 @@ import numpy as np import GPy -class SVGP_nonconvex(np.testing.TestCase): +class TestSVGP_nonconvex: """ Inference in the SVGP with a student-T likelihood """ - def setUp(self): + def setup(self): X = np.linspace(0, 10, 100).reshape(-1, 1) Z = np.linspace(0, 10, 10).reshape(-1, 1) Y = np.sin(X) + np.random.randn(*X.shape) * 0.1 @@ -18,15 +18,16 @@ class SVGP_nonconvex(np.testing.TestCase): self.m = GPy.core.SVGP(X, Y, Z=Z, likelihood=lik, kernel=k) def test_grad(self): + self.setup() assert self.m.checkgrad(step=1e-4) -class SVGP_classification(np.testing.TestCase): +class TestSVGP_classification: """ Inference in the SVGP with a Bernoulli likelihood """ - def setUp(self): + def setup(self): X = np.linspace(0, 10, 100).reshape(-1, 1) Z = np.linspace(0, 10, 10).reshape(-1, 1) Y = np.where((np.sin(X) + np.random.randn(*X.shape) * 0.1) > 0, 1, 0) @@ -36,15 +37,16 @@ class SVGP_classification(np.testing.TestCase): self.m = GPy.core.SVGP(X, Y, Z=Z, likelihood=lik, kernel=k) def test_grad(self): + self.setup() assert self.m.checkgrad(step=1e-4) -class SVGP_Poisson_with_meanfunction(np.testing.TestCase): +class TestSVGP_Poisson_with_meanfunction: """ Inference in the SVGP with a Bernoulli likelihood """ - def setUp(self): + def setup(self): X = np.linspace(0, 10, 100).reshape(-1, 1) Z = np.linspace(0, 10, 10).reshape(-1, 1) latent_f = np.exp(0.1 * X * 0.05 * X**2) @@ -57,4 +59,5 @@ class SVGP_Poisson_with_meanfunction(np.testing.TestCase): self.m = GPy.core.SVGP(X, Y, Z=Z, likelihood=lik, kernel=k, mean_function=mf) def test_grad(self): + self.setup() assert self.m.checkgrad(step=1e-4)