added m['ard'] gives all parameters matching 'ard', as well as setting m['ard'] = x to set all mrd parameters

This commit is contained in:
Max Zwiessele 2013-04-24 10:08:41 +01:00
parent 389a04d2b5
commit 70beeb5fe9
2 changed files with 94 additions and 111 deletions

View file

@ -83,6 +83,12 @@ class model(parameterised):
for w in which: for w in which:
self.priors[w] = what self.priors[w] = what
def __getitem__(self, name):
return self.get(name)
def __setitem(self, name, val):
return self.set(name, val)
def get(self, name, return_names=False): def get(self, name, return_names=False):
""" """
Get a model parameter by name. The name is applied as a regular expression and all parameters that match that regular expression are returned. Get a model parameter by name. The name is applied as a regular expression and all parameters that match that regular expression are returned.

View file

@ -287,29 +287,6 @@ class MRD(model):
else: else:
return pylab.gcf() return pylab.gcf()
def plot_X_1d(self, fig_num="MRD X 1d", axes=None, colors=None):
fig = pylab.figure(num=fig_num, figsize=(min(8, (3 * len(self.bgplvms))), min(12, (2 * self.X.shape[1]))))
if colors is None:
colors = pylab.gca()._get_lines.color_cycle
pylab.clf()
plots = []
for i in range(self.X.shape[1]):
if axes is None:
ax = fig.add_subplot(self.X.shape[1], 1, i + 1)
ax.plot(self.X, c='k', alpha=.3)
plots.extend(ax.plot(self.X.T[i], c=colors.next(), label=r"$\mathbf{{X_{}}}$".format(i)))
ax.fill_between(numpy.arange(self.X.shape[0]),
self.X.T[i] - 2 * numpy.sqrt(self.gref.X_variance.T[i]),
self.X.T[i] + 2 * numpy.sqrt(self.gref.X_variance.T[i]),
facecolor=plots[-1].get_color(),
alpha=.3)
ax.legend(borderaxespad=0.)
if i < self.X.shape[1] - 1:
ax.set_xticklabels('')
pylab.draw()
fig.tight_layout(h_pad=.01) # , rect=(0, 0, 1, .95))
return fig
def plot_X(self, fig_num="MRD Predictions", axes=None): def plot_X(self, fig_num="MRD Predictions", axes=None):
fig = self._handle_plotting(fig_num, axes, lambda i, g, ax: ax.imshow(g.X)) fig = self._handle_plotting(fig_num, axes, lambda i, g, ax: ax.imshow(g.X))
return fig return fig