mrd corrections

This commit is contained in:
mzwiessele 2014-01-28 10:38:54 +00:00
parent 06ad627f0a
commit 347e2e7fb0
2 changed files with 18 additions and 15 deletions

View file

@ -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,10 +206,11 @@ 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)
if warning:
overlap = set(matches).intersection(set(self.all_constrained_indices()))
if overlap:
self.unconstrain(np.asarray(list(overlap)))

View file

@ -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)