From fbaa3445a500d4860e6fc79c4028b605ccdd6e8e Mon Sep 17 00:00:00 2001 From: rozyczko Date: Wed, 21 Aug 2024 17:23:24 +0200 Subject: [PATCH] better checks on result object --- src/sas/qtgui/MainWindow/GuiManager.py | 2 +- src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py | 6 ++++-- src/sas/qtgui/Perspectives/Fitting/FittingWidget.py | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py index 6e445b56cd..f44238ebc0 100644 --- a/src/sas/qtgui/MainWindow/GuiManager.py +++ b/src/sas/qtgui/MainWindow/GuiManager.py @@ -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): diff --git a/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py b/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py index 453e35fd5f..256f615767 100644 --- a/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py +++ b/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py @@ -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: " + diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py b/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py index a18088347e..5353bdb038 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py @@ -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