Fix single-parameter rescaling in hooke.util.fit.ModelFitter
authorW. Trevor King <wking@drexel.edu>
Wed, 4 Aug 2010 15:53:33 +0000 (11:53 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 4 Aug 2010 15:53:33 +0000 (11:53 -0400)
hooke/util/fit.py

index aaa1ee4af974ae471c24ac872c51c2ddc716fddf..4ae0e18da3a42847ed9baaa1284c64b1ea19aa1e 100644 (file)
@@ -84,7 +84,7 @@ class ModelFitter (object):
     >>> m = LinearModel(data)
     >>> outqueue = Queue()
     >>> slope,offset = m.fit(outqueue=outqueue)
-    >>> info = outqueue.get()
+    >>> info = outqueue.get(block=False)
     >>> pprint(info)  # doctest: +ELLIPSIS, +REPORT_UDIFF
     {'active fitted parameters': array([  6.999..., -32.889...]),
      'active parameters': array([  6.999..., -32.889...]),
@@ -194,7 +194,11 @@ class ModelFitter (object):
             diag=active_scale, **kwargs)
         if self._rescale == True:
             active_params = params
-            params = [p*s for p,s in zip(params, self._param_scale_factors)]
+            if len(initial_params) == 1:  # params is a float
+                params = params * self._param_scale_factors[0]
+            else:
+                params = [p*s for p,s in zip(params,
+                                             self._param_scale_factors)]
         else:
             active_params = params
         if outqueue != None: