ModelFitter.fit() should always return a list (even for single-parameter fits).
authorW. Trevor King <wking@drexel.edu>
Fri, 5 Nov 2010 17:30:08 +0000 (10:30 -0700)
committerW. Trevor King <wking@drexel.edu>
Fri, 5 Nov 2010 17:30:08 +0000 (10:30 -0700)
pysawsim/fit.py

index 377d9835454fe05e28327d59c08eb8b902f6f482..6b325da6edc251ade8b1f6ae55dd6640f3e43035 100755 (executable)
@@ -265,13 +265,11 @@ class ModelFitter (object):
         params,cov,info,mesg,ier = leastsq(
             func=self.residual, x0=active_params, full_output=True,
             diag=scale, **kwargs)
+        if len(initial_params) == 1:
+            params = [params]
         if self._rescale == True:
             active_params = params
-            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)]
+            params = [p*s for p,s in zip(params, self._param_scale_factors)]
         else:
             active_params = params
         self.fit_info = {