Fix GPy.priors.InverseGamma (#903)

* fixed InverseGamma prior: beforehand, it was a child class of Gamma but it defined a broken __new__ method of its own. Now, it just inherits Gamma's __new__; also added a test that ensures the InverseGamma can be instantiated and integrated into a GPy model

* overwrote misleading inherited methods in InverseGamma, deleted unnecessary repeated code
This commit is contained in:
Eric Kalosa-Kenyon 2021-05-26 17:37:55 -07:00 committed by GitHub
parent 88d4fbf2c0
commit 62d735e6a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions

View file

@ -55,6 +55,21 @@ class PriorTests(unittest.TestCase):
m.randomize()
self.assertTrue(m.checkgrad())
def test_InverseGamma(self):
# Test that this prior object can be instantiated and performs its basic functions
# in integration.
xmin, xmax = 1, 2.5*np.pi
b, C, SNR = 1, 0, 0.1
X = np.linspace(xmin, xmax, 500)
y = b*X + C + 1*np.sin(X)
y += 0.05*np.random.randn(len(X))
X, y = X[:, None], y[:, None]
m = GPy.models.GPRegression(X, y)
InverseGamma = GPy.priors.InverseGamma(1, 1)
m.rbf.set_prior(InverseGamma)
m.randomize()
self.assertTrue(m.checkgrad())
def test_incompatibility(self):
xmin, xmax = 1, 2.5*np.pi
b, C, SNR = 1, 0, 0.1