Skip to content

Commit

Permalink
least-squares optimization failure should not raise an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
moustakas committed Jan 7, 2025
1 parent c93de58 commit 857a1af
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions py/fastspecfit/emlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,13 @@ def optimize(self, linemodel,
fit_info = least_squares(objective, initial_guesses, jac=jac, args=(),
max_nfev=5000, xtol=1e-10, ftol=1e-5, #x_scale='jac' gtol=1e-10,
tr_solver='lsmr', tr_options={'maxiter': 1000, 'regularize': True},
method='trf', bounds=bounds,) # verbose=2)
method='trf', bounds=bounds)#, verbose=2)
free_params = fit_info.x

if not fit_info.success:
errmsg = 'least_squares optimizer failed' + \
(f' for {self.uniqueid}' if self.uniqueid is not None else '')
log.critical(errmsg)
raise RuntimeError(errmsg)
elif fit_info.status == 0:
log.warning('optimizer failed to converge')

Expand Down

0 comments on commit 857a1af

Please sign in to comment.