Skip to content

Commit

Permalink
foolproof the fitter against bump's antics
Browse files Browse the repository at this point in the history
  • Loading branch information
rozyczko committed Jan 8, 2025
1 parent e85db92 commit 2b139fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/sas/qtgui/Perspectives/Fitting/FitThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ def map_getattr(classInstance, classFunc, *args):
Take an instance of a class and a function name as a string.
Execute class.function and return result
"""
return getattr(classInstance, classFunc)(*args)
try:
return_value = getattr(classInstance, classFunc)(*args)
except Exception as ex:
logger.error("Fitting failed: %s", traceback.format_exc())
return None
return return_value

def map_apply(arguments):
return arguments[0](*arguments[1:])
try:
return_value = arguments[0](*arguments[1:])
except Exception as ex:
logger.error("Fitting failed: %s", traceback.format_exc())
return None
return return_value

class FitThread(CalcThread):
"""Thread performing the fit """
Expand Down
4 changes: 3 additions & 1 deletion src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,9 +2108,11 @@ def fitComplete(self, result):
#re-enable the Fit button
self.enableInteractiveElements()

if len(result) == 0:
if result is None or len(result) == 0 or result[0] is None or len(result[0]) == 0 or result[0][0] is None or len(result[0][0]) == 0:
msg = "Fitting failed."
self.communicate.statusBarUpdateSignal.emit(msg)
# reload the kernel_module in case it's corrupted
self.kernel_module = copy.deepcopy(self.kernel_module_copy)
return

# Don't recalculate chi2 - it's in res.fitness already
Expand Down

0 comments on commit 2b139fb

Please sign in to comment.