parameterized: added warning switch

This commit is contained in:
mzwiessele 2014-01-28 12:05:23 +00:00
parent 347e2e7fb0
commit 50db3a90e9
2 changed files with 12 additions and 11 deletions

View file

@ -225,7 +225,7 @@ class Parameterized(object):
x[matches] = transform.initialize(x[matches]) x[matches] = transform.initialize(x[matches])
self._set_params(x) self._set_params(x)
def constrain_fixed(self, regexp, value=None): def constrain_fixed(self, regexp, value=None, warning=True):
""" """
:param regexp: which parameters need to be fixed. :param regexp: which parameters need to be fixed.
@ -242,13 +242,14 @@ class Parameterized(object):
""" """
matches = self.grep_param_names(regexp) matches = self.grep_param_names(regexp)
overlap = set(matches).intersection(set(self.all_constrained_indices())) if warning:
if overlap: overlap = set(matches).intersection(set(self.all_constrained_indices()))
self.unconstrain(np.asarray(list(overlap))) if overlap:
print 'Warning: re-constraining these parameters' self.unconstrain(np.asarray(list(overlap)))
pn = self._get_param_names() print 'Warning: re-constraining these parameters'
for i in overlap: pn = self._get_param_names()
print pn[i] for i in overlap:
print pn[i]
self.fixed_indices.append(matches) self.fixed_indices.append(matches)
if value != None: if value != None:

View file

@ -327,9 +327,9 @@ class MRD(Model):
if titles is None: if titles is None:
titles = [r'${}$'.format(name) for name in self.names] titles = [r'${}$'.format(name) for name in self.names]
ymax = reduce(max, [numpy.ceil(max(g.input_sensitivity())) for g in self.bgplvms]) ymax = reduce(max, [numpy.ceil(max(g.input_sensitivity())) for g in self.bgplvms])
def plotf(i, g, ax): def plotf(i, g, axis):
ax.set_ylim([0,ymax]) axis.set_ylim([0,ymax])
g.kern.plot_ARD(ax=ax, title=titles[i], *args, **kwargs) g.kern.plot_ARD(ax=axis, title=titles[i], *args, **kwargs)
fig = self._handle_plotting(fignum, ax, plotf, sharex=sharex, sharey=sharey) fig = self._handle_plotting(fignum, ax, plotf, sharex=sharex, sharey=sharey)
return fig return fig