testing: refactor test-model class due to naming confusion with pytest

This commit is contained in:
Martin Bubel 2024-01-14 19:10:42 +01:00
parent d5724d521a
commit 986bc5b84e

View file

@ -9,13 +9,13 @@ import scipy.stats as st
import GPy import GPy
class TestModel(GPy.core.Model): class Model(GPy.core.Model):
""" """
A simple GPy model with one parameter. A simple GPy model with one parameter.
""" """
def __init__(self, theta=1.0): def __init__(self, theta=1.0):
super(TestModel, self).__init__("test_model") super(Model, self).__init__("test_model")
theta = GPy.core.Param("theta", theta) theta = GPy.core.Param("theta", theta)
self.link_parameter(theta) self.link_parameter(theta)
@ -25,7 +25,7 @@ class TestModel(GPy.core.Model):
class TestRVTransformation: class TestRVTransformation:
def _test_trans(self, trans): def _test_trans(self, trans):
m = TestModel() m = Model()
prior = GPy.priors.LogGaussian(0.5, 0.1) prior = GPy.priors.LogGaussian(0.5, 0.1)
m.theta.set_prior(prior) m.theta.set_prior(prior)
m.theta.unconstrain() m.theta.unconstrain()
@ -57,7 +57,7 @@ class TestRVTransformation:
def _test_grad(self, trans): def _test_grad(self, trans):
np.random.seed(1234) np.random.seed(1234)
m = TestModel(np.random.uniform(0.5, 1.5, 20)) m = Model(np.random.uniform(0.5, 1.5, 20))
prior = GPy.priors.LogGaussian(0.5, 0.1) prior = GPy.priors.LogGaussian(0.5, 0.1)
m.theta.set_prior(prior) m.theta.set_prior(prior)
m.theta.constrain(trans) m.theta.constrain(trans)