From eb506c1fb4282b43b8b04ea36492f9f3d1c17d50 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 4 Aug 2010 11:53:33 -0400 Subject: [PATCH] Fix single-parameter rescaling in hooke.util.fit.ModelFitter --- hooke/util/fit.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hooke/util/fit.py b/hooke/util/fit.py index aaa1ee4..4ae0e18 100644 --- a/hooke/util/fit.py +++ b/hooke/util/fit.py @@ -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: -- 2.26.2