mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 12:32:40 +02:00
[tests] for issue ##146 and #147, fixing parameters inside __init__
This commit is contained in:
parent
5ab16915a9
commit
d263432dde
3 changed files with 26 additions and 1 deletions
|
|
@ -447,6 +447,7 @@ class GradientTests(np.testing.TestCase):
|
|||
m = GPy.models.GPHeteroscedasticRegression(X, Y, kern)
|
||||
self.assertTrue(m.checkgrad())
|
||||
|
||||
|
||||
def test_gp_kronecker_gaussian(self):
|
||||
N1, N2 = 30, 20
|
||||
X1 = np.random.randn(N1, 1)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ class Test(unittest.TestCase):
|
|||
self.assertEqual(self._first, self._trigger, 'priority should be second')
|
||||
self.assertEqual(self._second, self._trigger_priority, 'priority should be second')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
#import sys;sys.argv = ['', 'Test.testName']
|
||||
unittest.main()
|
||||
|
|
@ -221,6 +221,31 @@ class ParameterizedTest(unittest.TestCase):
|
|||
np.testing.assert_equal(t.x.constraints[Logistic(0,1)], c[Logistic(0,1)])
|
||||
np.testing.assert_equal(t.x.constraints['fixed'], c['fixed'])
|
||||
|
||||
def test_parameter_modify_in_init(self):
|
||||
class TestLikelihood(Parameterized):
|
||||
def __init__(self, param1 = 2., param2 = 3.):
|
||||
super(TestLikelihood, self).__init__("TestLike")
|
||||
self.p1 = Param('param1', param1)
|
||||
self.p2 = Param('param2', param2)
|
||||
|
||||
self.link_parameter(self.p1)
|
||||
self.link_parameter(self.p2)
|
||||
|
||||
self.p1.fix()
|
||||
self.p1.unfix()
|
||||
self.p2.constrain_negative()
|
||||
self.p1.fix()
|
||||
self.p2.constrain_positive()
|
||||
self.p2.fix()
|
||||
self.p2.constrain_positive()
|
||||
|
||||
m = TestLikelihood()
|
||||
print m
|
||||
val = m.p1.values.copy()
|
||||
self.assert_(m.p1.is_fixed)
|
||||
self.assert_(m.constraints[GPy.constraints.Logexp()].tolist(), [1])
|
||||
m.randomize()
|
||||
self.assertEqual(m.p1, val)
|
||||
|
||||
def test_printing(self):
|
||||
print self.test1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue