tried to eliminate the regexp overflow error for large models

This commit is contained in:
James Hensman 2013-05-07 18:50:13 +01:00
parent ce2884f0a7
commit 8f75f6d66b

View file

@ -203,7 +203,7 @@ class model(parameterised):
else: else:
self._set_params_transformed(initial_parameters) self._set_params_transformed(initial_parameters)
def ensure_default_constraints(self, warn=False): def ensure_default_constraints(self):
""" """
Ensure that any variables which should clearly be positive have been constrained somehow. Ensure that any variables which should clearly be positive have been constrained somehow.
""" """
@ -214,11 +214,11 @@ class model(parameterised):
for s in positive_strings: for s in positive_strings:
for i in self.grep_param_names(s): for i in self.grep_param_names(s):
if not (i in currently_constrained): if not (i in currently_constrained):
to_make_positive.append(re.escape(param_names[i])) #to_make_positive.append(re.escape(param_names[i]))
if warn: to_make_positive.append(i)
print "Warning! constraining %s positive" % s
if len(to_make_positive): if len(to_make_positive):
self.constrain_positive('(' + '|'.join(to_make_positive) + ')') #self.constrain_positive('(' + '|'.join(to_make_positive) + ')')
self.constrain_positive(np.asarray(to_make_positive))