Avoid possible negative p[2] values in SurfacePositionModel.
authorW. Trevor King <wking@drexel.edu>
Mon, 14 Jun 2010 14:08:21 +0000 (10:08 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 14 Jun 2010 14:08:21 +0000 (10:08 -0400)
hooke/plugin/vclamp.py

index c57c11a37db2df714783d981b8e9461c06f62e55..0dfaeab2bdd08dec77df256666a65a271381dad7 100644 (file)
@@ -97,7 +97,7 @@ class SurfacePositionModel (ModelFitter):
         if self.info.get('force zero non-contact slope', None) == True:
             p = list(p)
             p.append(0.)  # restore the non-contact slope parameter
-        r2 = numpy.round(p[2])
+        r2 = numpy.round(abs(p[2]))
         if r2 >= 1:
             self._model_data[:r2] = p[0] + p[1] * numpy.arange(r2)
         if r2 < len(self._data)-1:
@@ -165,6 +165,7 @@ class SurfacePositionModel (ModelFitter):
     def fit(self, *args, **kwargs):
         self.info['guessed contact slope'] = None
         params = super(SurfacePositionModel, self).fit(*args, **kwargs)
+        params[2] = abs(params[2])
         if self.info.get('force zero non-contact slope', None) == True:
             params = list(params)
             params.append(0.)  # restore the non-contact slope parameter