Skip to content

Commit

Permalink
correctly create non-constraint parameter values and bounds for least…
Browse files Browse the repository at this point in the history
…_squares()
  • Loading branch information
newville committed May 31, 2017
1 parent 6122a77 commit c2b7ea1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lmfit/minimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,9 +1204,13 @@ def least_squares(self, params=None, **kws):
result.method = 'least_squares'

replace_none = lambda x, sign: sign*np.inf if x is None else x
upper_bounds = [replace_none(i.max, 1) for i in self.params.values()]
lower_bounds = [replace_none(i.min, -1) for i in self.params.values()]
start_vals = [i.value for i in self.params.values()]

start_vals, lower_bounds, upper_bounds = [], [], []
for vname in result.var_names:
par = self.params[vname]
start_vals.append(par.value)
lower_bounds.append(replace_none(par.min, -1))
upper_bounds.append(replace_none(par.max, -1))

ret = least_squares(self.__residual, start_vals,
bounds=(lower_bounds, upper_bounds),
Expand Down

0 comments on commit c2b7ea1

Please sign in to comment.