Fixed parameter bugs

This commit is contained in:
Alan Saul 2014-02-07 15:16:05 +00:00
parent 648609c3b1
commit c28f11f291
2 changed files with 10 additions and 6 deletions

View file

@ -449,6 +449,8 @@ class Parameterized(Constrainable, Pickleable, Observable):
# if removing constraints before adding new is not wanted, just delete the above line! # if removing constraints before adding new is not wanted, just delete the above line!
self.constraints.add(transform, rav_i) self.constraints.add(transform, rav_i)
param = self._get_original(param) param = self._get_original(param)
#FIXME: Max, is this the right thing to do to handle fixed?
if not (transform == __fixed__):
param._set_params(transform.initialize(param._get_params()), update=False) param._set_params(transform.initialize(param._get_params()), update=False)
if warning and any(reconstrained): if warning and any(reconstrained):
# if you want to print the whole params object, which was reconstrained use: # if you want to print the whole params object, which was reconstrained use:

View file

@ -162,7 +162,9 @@ class Logistic(Transformation):
def initialize(self, f): def initialize(self, f):
if np.any(np.logical_or(f < self.lower, f > self.upper)): if np.any(np.logical_or(f < self.lower, f > self.upper)):
print "Warning: changing parameters to satisfy constraints" print "Warning: changing parameters to satisfy constraints"
return np.where(np.logical_or(f < self.lower, f > self.upper), self.f(f * 0.), f) #return np.where(np.logical_or(f < self.lower, f > self.upper), self.f(f * 0.), f)
#FIXME: Max, zeros_like right?
return np.where(np.logical_or(f < self.lower, f > self.upper), self.f(np.zeros_like(f)), f)
def __str__(self): def __str__(self):
return '{},{}'.format(self.lower, self.upper) return '{},{}'.format(self.lower, self.upper)