Skip to content

Commit

Permalink
better checks on result object
Browse files Browse the repository at this point in the history
  • Loading branch information
rozyczko committed Aug 21, 2024
1 parent 790d628 commit fbaa344
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sas/qtgui/MainWindow/GuiManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ def showFitResults(self, output_data):
Show bumps convergence plots
"""
self.results_frame.setVisible(True)
if output_data:
if output_data and len(output_data) > 0 and len(output_data[0]) > 0:
self.results_panel.onPlotResults(output_data, optimizer=self.perspective().optimizer)

def actionAdd_Custom_Model(self):
Expand Down
6 changes: 4 additions & 2 deletions src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,15 @@ def fitComplete(self, result):
self.parent.communicate.statusBarUpdateSignal.emit(msg)
return

# Get the results list
results = result[0][0]
if isinstance(result[0], str):
msg = ("Fitting failed with the following message: " +
result[0])
self.parent.communicate.statusBarUpdateSignal.emit(msg)
return

# Get the results list
results = result[0][0]

if not results[0].success:
if isinstance(results[0].mesg[0], str):
msg = ("Fitting failed with the following message: " +
Expand Down
4 changes: 4 additions & 0 deletions src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,10 @@ def fitComplete(self, result):

# Don't recalculate chi2 - it's in res.fitness already
self.fitResults = True
if result is None or len(result) == 0 or len(result[0]) == 0:
msg = "Fitting failed."
self.communicate.statusBarUpdateSignal.emit(msg)
return
res_list = result[0][0]
res = res_list[0]
self.chi2 = res.fitness
Expand Down

0 comments on commit fbaa344

Please sign in to comment.