forked from IPKM/nmreval
add logging to fit exception to retain more info and find problem with #56; all references to current graph are either None or id, should close #57
This commit is contained in:
@ -9,6 +9,7 @@ from numpy import geomspace, linspace
|
||||
from pyqtgraph import ViewBox
|
||||
|
||||
from nmreval.configs import *
|
||||
from nmreval.lib.logger import logger
|
||||
from nmreval.io.sessionwriter import NMRWriter
|
||||
|
||||
from .management import UpperManagement
|
||||
@ -128,7 +129,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
|
||||
self.datawidget.management = self.management
|
||||
self.integralwidget.management = self.management
|
||||
self.drawingswidget.graphs = self.management.graphs
|
||||
# self.drawingswidget.graphs = self.management.graphs
|
||||
|
||||
self.ac_group = QtWidgets.QActionGroup(self)
|
||||
self.ac_group.addAction(self.action_lm_fit)
|
||||
@ -161,7 +162,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
self.actionPick_position.triggered.connect(lambda: self._show_tab('pick'))
|
||||
self.actionIntegration.triggered.connect(lambda: self._show_tab('integrate'))
|
||||
self.action_FitWidget.triggered.connect(lambda: self._show_tab('fit'))
|
||||
self.action_draw_object.triggered.connect(lambda: self._show_tab('drawing'))
|
||||
|
||||
self.action_new_set.triggered.connect(self.management.create_empty)
|
||||
|
||||
@ -389,7 +389,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
self.current_graph_widget.enable_picking(False)
|
||||
|
||||
self.current_graph_widget = None
|
||||
self.management.current_graph = ''
|
||||
self.management.current_graph = None
|
||||
self.current_plotitem = None
|
||||
|
||||
wdgt.setParent(None)
|
||||
@ -493,7 +493,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
'signal': (self.editsignalwidget, 'Signals'),
|
||||
'pick': (self.ptsselectwidget, 'Pick points'),
|
||||
'fit': (self.fit_dialog, 'Fit'),
|
||||
'drawing': (self.drawingswidget, 'Draw'),
|
||||
'integrate': (self.integralwidget, 'Integrate'),
|
||||
}[mode]
|
||||
|
||||
@ -905,7 +904,9 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
|
||||
@QtCore.pyqtSlot(dict, int, bool)
|
||||
def show_fit_preview(self, funcs: dict, num: int, show: bool):
|
||||
if self.fit_dialog.connected_figure is None:
|
||||
if not self.fit_dialog.connected_figure:
|
||||
logger.warning(f'Fit dialog is not connected graph: Fit {self.fit_dialog.connected_figure}, '
|
||||
f'current graph: {self.management.current_graph} ({self.management.current_graph in self.management.graphs})')
|
||||
return
|
||||
|
||||
g = self.management.graphs[self.fit_dialog.connected_figure]
|
||||
|
@ -110,7 +110,7 @@ class UpperManagement(QtCore.QObject):
|
||||
self.counter = 0
|
||||
self.data = OrderedDict()
|
||||
self.window = window
|
||||
self.current_graph = ''
|
||||
self.current_graph = None
|
||||
self.graphs = GraphDict(self.data)
|
||||
self.namespace = None
|
||||
self.undostack = QtWidgets.QUndoStack()
|
||||
@ -489,12 +489,14 @@ class UpperManagement(QtCore.QObject):
|
||||
|
||||
@QtCore.pyqtSlot(list, bool)
|
||||
def end_fit(self, result: list, success: bool):
|
||||
logger.info('FIT FINISHED')
|
||||
if success:
|
||||
logger.info('Successful fit')
|
||||
self.fitFinished.emit(result)
|
||||
else:
|
||||
e = result[0]
|
||||
logger.exception(e, exc_info=True)
|
||||
QtWidgets.QMessageBox.warning(QtWidgets.QWidget(), 'Fit failed',
|
||||
'Fit kaput with exception: \n' + "\n".join(result[0]))
|
||||
f'Fit kaput with exception: \n\n{e!r}')
|
||||
self.fitFinished.emit([])
|
||||
self._fit_active = False
|
||||
|
||||
@ -1213,6 +1215,6 @@ class FitWorker(QtCore.QObject):
|
||||
res = self.fitter.run(mode=self.mode)
|
||||
success = True
|
||||
except Exception as e:
|
||||
res = [e.args]
|
||||
res = [e]
|
||||
success = False
|
||||
self.finished.emit(res, success)
|
||||
|
Reference in New Issue
Block a user