From 7e36ee956a4829951b07b4da777cf58235630af2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 14 Jun 2010 10:08:21 -0400 Subject: [PATCH] Avoid possible negative p[2] values in SurfacePositionModel. --- hooke/plugin/vclamp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooke/plugin/vclamp.py b/hooke/plugin/vclamp.py index c57c11a..0dfaeab 100644 --- a/hooke/plugin/vclamp.py +++ b/hooke/plugin/vclamp.py @@ -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 -- 2.26.2