mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-13 05:52:38 +02:00
[#133] fix: chainging constraint in __init__
This commit is contained in:
parent
bccd8e094a
commit
ac4dbb851d
3 changed files with 28 additions and 3 deletions
|
|
@ -8,7 +8,9 @@ import GPy
|
|||
import numpy as np
|
||||
from GPy.core.parameterization.parameter_core import HierarchyError
|
||||
from GPy.core.parameterization.observable_array import ObsAr
|
||||
from GPy.core.parameterization.transformations import NegativeLogexp
|
||||
from GPy.core.parameterization.transformations import NegativeLogexp, Logistic
|
||||
from GPy.core.parameterization.parameterized import Parameterized
|
||||
from GPy.core.parameterization.param import Param
|
||||
|
||||
class ArrayCoreTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -198,6 +200,20 @@ class ParameterizedTest(unittest.TestCase):
|
|||
unfixed = self.testmodel.kern.unfix()
|
||||
self.assertListEqual(unfixed.tolist(), [0,1])
|
||||
|
||||
def test_constraints_in_init(self):
|
||||
class Test(Parameterized):
|
||||
def __init__(self, name=None, parameters=[], *a, **kw):
|
||||
super(Test, self).__init__(name=name)
|
||||
self.x = Param('x', np.random.uniform(0,1,(3,4)))
|
||||
self.x[0].constrain_bounded(0,1)
|
||||
self.link_parameter(self.x)
|
||||
self.x[1].fix()
|
||||
t = Test()
|
||||
c = {Logistic(0,1): np.array([0, 1, 2, 3]), 'fixed': np.array([4, 5, 6, 7])}
|
||||
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_printing(self):
|
||||
print self.test1
|
||||
print self.param
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue