observer pattern now tested and fully operational. needed the good night rest : )

This commit is contained in:
Max Zwiessele 2014-02-28 08:58:34 +00:00
parent a35464b32f
commit 999d2419dd
6 changed files with 158 additions and 20 deletions

View file

@ -116,6 +116,7 @@ class Parameterized(Parameterizable, Pickleable, Gradcheckable):
self.constraints.update(param.constraints, start)
self.priors.update(param.priors, start)
self._parameters_.insert(index, param)
param.add_observer(self, self._pass_through_notify, -1)
self.size += param.size
else:
raise RuntimeError, """Parameter exists already added and no copy made"""
@ -169,6 +170,12 @@ class Parameterized(Parameterizable, Pickleable, Gradcheckable):
self._param_slices_.append(slice(sizes[-2], sizes[-1]))
self._add_parameter_name(p)
#===========================================================================
# notification system
#===========================================================================
def _pass_through_notify(self, which):
self._notify_observers(which)
#===========================================================================
# Pickling operations
#===========================================================================