From 347e2e7fb00e2d60b5b4bda29a2628f57b87a7a6 Mon Sep 17 00:00:00 2001 From: mzwiessele Date: Tue, 28 Jan 2014 10:38:54 +0000 Subject: [PATCH] mrd corrections --- GPy/core/parameterized.py | 29 +++++++++++++++-------------- GPy/models_modules/mrd.py | 4 +++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/GPy/core/parameterized.py b/GPy/core/parameterized.py index 0e08e2c0..5d5184da 100644 --- a/GPy/core/parameterized.py +++ b/GPy/core/parameterized.py @@ -188,17 +188,17 @@ class Parameterized(object): else: self.fixed_indices, self.fixed_values = [], [] - def constrain_negative(self, regexp): + def constrain_negative(self, regexp, warning=True): """ Set negative constraints. """ - self.constrain(regexp, transformations.negative_logexp()) + self.constrain(regexp, transformations.negative_logexp(), warning=warning) - def constrain_positive(self, regexp): + def constrain_positive(self, regexp, warning=True): """ Set positive constraints. """ - self.constrain(regexp, transformations.logexp()) + self.constrain(regexp, transformations.logexp(), warning=warning) - def constrain_bounded(self, regexp, lower, upper): + def constrain_bounded(self, regexp, lower, upper, warning=True): """ Set bounded constraints. """ - self.constrain(regexp, transformations.logistic(lower, upper)) + self.constrain(regexp, transformations.logistic(lower, upper), warning=warning) def all_constrained_indices(self): if len(self.constrained_indices) or len(self.fixed_indices): @@ -206,17 +206,18 @@ class Parameterized(object): else: return np.empty(shape=(0,)) - def constrain(self, regexp, transform): + def constrain(self, regexp, transform, warning=True): assert isinstance(transform, transformations.transformation) matches = self.grep_param_names(regexp) - overlap = set(matches).intersection(set(self.all_constrained_indices())) - if overlap: - self.unconstrain(np.asarray(list(overlap))) - print 'Warning: re-constraining these parameters' - pn = self._get_param_names() - for i in overlap: - print pn[i] + if warning: + overlap = set(matches).intersection(set(self.all_constrained_indices())) + if overlap: + self.unconstrain(np.asarray(list(overlap))) + print 'Warning: re-constraining these parameters' + pn = self._get_param_names() + for i in overlap: + print pn[i] self.constrained_indices.append(matches) self.constraints.append(transform) diff --git a/GPy/models_modules/mrd.py b/GPy/models_modules/mrd.py index 862b697b..cc962bd9 100644 --- a/GPy/models_modules/mrd.py +++ b/GPy/models_modules/mrd.py @@ -46,7 +46,9 @@ class MRD(Model): initz='permute', _debug=False, **kw): if names is None: self.names = ["{}".format(i) for i in range(len(likelihood_or_Y_list))] - + else: + self.names = names + assert len(names) == len(likelihood_or_Y_list), "one name per data set required" # sort out the kernels if kernels is None: kernels = [None] * len(likelihood_or_Y_list)