import copy
import sys

import scipy

import SloppyCell.KeyedList_mod as KeyedList_mod
KeyedList = KeyedList_mod.KeyedList

def fmin_powell_log_params(m, params, *args, **kwargs):
    func = m.cost_log_params

    pmin = scipy.optimize.fmin_powell(func, scipy.log(params), 
                                      *args, **kwargs)
    if isinstance(params, KeyedList):
        pout = params.copy()
        pout.update(scipy.exp(pmin))
        return pout
    else:
        return scipy.exp(pmin)

def fmin_log_params(m, params, *args, **kwargs):
    func = m.cost_log_params

    pmin = scipy.optimize.fmin(func, scipy.log(params),
                               *args, **kwargs)

    if isinstance(params, KeyedList):
        pout = params.copy()
        pout.update(scipy.exp(pmin))
        return pout
    else:
        return scipy.exp(pmin)

def leastsq_log_params(m, params, *args, **kwargs):
    func = m.res_log_params

    pmin, msg = scipy.optimize.leastsq(func, scipy.log(params), *args, **kwargs)

    if isinstance(params, KeyedList):
        pout = params.copy()
        pout.update(scipy.exp(pmin))
        return pout
    else:
        return scipy.exp(pmin)

import copy
import sys

import scipy

import SloppyCell.KeyedList_mod as KeyedList_mod
KeyedList = KeyedList_mod.KeyedList

def fmin_powell_log_params(m, params, *args, **kwargs):
    func = m.cost_log_params

    pmin = scipy.optimize.fmin_powell(func, scipy.log(params), 
                                      *args, **kwargs)
    if isinstance(params, KeyedList):
        pout = params.copy()
        pout.update(scipy.exp(pmin))

    return pout

def fmin_log_params(m, params, *args, **kwargs):
    func = m.cost_log_params

    pmin = scipy.optimize.fmin(func, scipy.log(params),
                               *args, **kwargs)

    if isinstance(params, KeyedList):
        pout = params.copy()
        pout.update(scipy.exp(pmin))
    return pout

def leastsq_log_params(m, params, *args, **kwargs):
    func = m.res_log_params

    pmin, msg = scipy.optimize.leastsq(func, scipy.log(params), *args, **kwargs)

    if isinstance(params, KeyedList):
        pout = params.copy()
        pout.update(scipy.exp(pmin))
    return pout

--- 
+++ 
@@ -14,8 +14,9 @@
     if isinstance(params, KeyedList):
         pout = params.copy()
         pout.update(scipy.exp(pmin))
-
-    return pout
+        return pout
+    else:
+        return scipy.exp(pmin)
 
 def fmin_log_params(m, params, *args, **kwargs):
     func = m.cost_log_params
@@ -26,7 +27,9 @@
     if isinstance(params, KeyedList):
         pout = params.copy()
         pout.update(scipy.exp(pmin))
-    return pout
+        return pout
+    else:
+        return scipy.exp(pmin)
 
 def leastsq_log_params(m, params, *args, **kwargs):
     func = m.res_log_params
@@ -36,4 +39,6 @@
     if isinstance(params, KeyedList):
         pout = params.copy()
         pout.update(scipy.exp(pmin))
-    return pout
+        return pout
+    else:
+        return scipy.exp(pmin)
Fix to handle case where parameters are not passed-in as a KL
