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:
parent
adcd98fc31
commit
75ec462efd
@ -64,9 +64,6 @@ class Ui_BaseWindow(object):
|
|||||||
icon5 = QtGui.QIcon()
|
icon5 = QtGui.QIcon()
|
||||||
icon5.addPixmap(QtGui.QPixmap(":/eval_t1_dock"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon5.addPixmap(QtGui.QPixmap(":/eval_t1_dock"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.tabWidget.addTab(self.t1tauwidget, icon5, "")
|
self.tabWidget.addTab(self.t1tauwidget, icon5, "")
|
||||||
self.drawingswidget = DrawingsWidget()
|
|
||||||
self.drawingswidget.setObjectName("drawingswidget")
|
|
||||||
self.tabWidget.addTab(self.drawingswidget, "")
|
|
||||||
self.integralwidget = IntegralWidget()
|
self.integralwidget = IntegralWidget()
|
||||||
self.integralwidget.setObjectName("integralwidget")
|
self.integralwidget.setObjectName("integralwidget")
|
||||||
self.tabWidget.addTab(self.integralwidget, "")
|
self.tabWidget.addTab(self.integralwidget, "")
|
||||||
@ -356,8 +353,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionUpdate.setObjectName("actionUpdate")
|
self.actionUpdate.setObjectName("actionUpdate")
|
||||||
self.actionMine = QtWidgets.QAction(BaseWindow)
|
self.actionMine = QtWidgets.QAction(BaseWindow)
|
||||||
self.actionMine.setObjectName("actionMine")
|
self.actionMine.setObjectName("actionMine")
|
||||||
self.action_draw_object = QtWidgets.QAction(BaseWindow)
|
|
||||||
self.action_draw_object.setObjectName("action_draw_object")
|
|
||||||
self.actionBugs = QtWidgets.QAction(BaseWindow)
|
self.actionBugs = QtWidgets.QAction(BaseWindow)
|
||||||
self.actionBugs.setObjectName("actionBugs")
|
self.actionBugs.setObjectName("actionBugs")
|
||||||
self.actionShow_error_log = QtWidgets.QAction(BaseWindow)
|
self.actionShow_error_log = QtWidgets.QAction(BaseWindow)
|
||||||
@ -446,7 +441,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.menuWindow.addSeparator()
|
self.menuWindow.addSeparator()
|
||||||
self.menuWindow.addAction(self.actionRefresh)
|
self.menuWindow.addAction(self.actionRefresh)
|
||||||
self.menuWindow.addSeparator()
|
self.menuWindow.addSeparator()
|
||||||
self.menuWindow.addAction(self.action_draw_object)
|
|
||||||
self.menuNMR.addAction(self.t1action)
|
self.menuNMR.addAction(self.t1action)
|
||||||
self.menuNMR.addAction(self.actionCalculateT1)
|
self.menuNMR.addAction(self.actionCalculateT1)
|
||||||
self.menuNMR.addAction(self.action_coup_calc)
|
self.menuNMR.addAction(self.action_coup_calc)
|
||||||
@ -505,7 +499,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.editsignalwidget), _translate("BaseWindow", "Signals"))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.editsignalwidget), _translate("BaseWindow", "Signals"))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.ptsselectwidget), _translate("BaseWindow", "Pick points"))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.ptsselectwidget), _translate("BaseWindow", "Pick points"))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t1tauwidget), _translate("BaseWindow", "SLR"))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t1tauwidget), _translate("BaseWindow", "SLR"))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.drawingswidget), _translate("BaseWindow", "Drawings"))
|
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.integralwidget), _translate("BaseWindow", "Integrate"))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.integralwidget), _translate("BaseWindow", "Integrate"))
|
||||||
self.menuFile.setTitle(_translate("BaseWindow", "&File"))
|
self.menuFile.setTitle(_translate("BaseWindow", "&File"))
|
||||||
self.menuSave.setTitle(_translate("BaseWindow", "&Save..."))
|
self.menuSave.setTitle(_translate("BaseWindow", "&Save..."))
|
||||||
@ -574,7 +567,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionFit_parameter_saving.setText(_translate("BaseWindow", "Fit parameter saving..."))
|
self.actionFit_parameter_saving.setText(_translate("BaseWindow", "Fit parameter saving..."))
|
||||||
self.actionShow_fit_parameter.setText(_translate("BaseWindow", "Parameter..."))
|
self.actionShow_fit_parameter.setText(_translate("BaseWindow", "Parameter..."))
|
||||||
self.actionSkip_points.setText(_translate("BaseWindow", "Skip points..."))
|
self.actionSkip_points.setText(_translate("BaseWindow", "Skip points..."))
|
||||||
self.actionGuide_lines.setText(_translate("BaseWindow", "Draw lines..."))
|
|
||||||
self.actionMaximize.setText(_translate("BaseWindow", "Maximize"))
|
self.actionMaximize.setText(_translate("BaseWindow", "Maximize"))
|
||||||
self.actionTile.setText(_translate("BaseWindow", "Tile windows"))
|
self.actionTile.setText(_translate("BaseWindow", "Tile windows"))
|
||||||
self.actionTileVertical.setText(_translate("BaseWindow", "Tile windows vertically"))
|
self.actionTileVertical.setText(_translate("BaseWindow", "Tile windows vertically"))
|
||||||
@ -622,7 +614,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionTetris.setText(_translate("BaseWindow", "Not Tetris"))
|
self.actionTetris.setText(_translate("BaseWindow", "Not Tetris"))
|
||||||
self.actionUpdate.setText(_translate("BaseWindow", "Look for updates"))
|
self.actionUpdate.setText(_translate("BaseWindow", "Look for updates"))
|
||||||
self.actionMine.setText(_translate("BaseWindow", "Mine"))
|
self.actionMine.setText(_translate("BaseWindow", "Mine"))
|
||||||
self.action_draw_object.setText(_translate("BaseWindow", "Draw objects..."))
|
|
||||||
self.actionBugs.setText(_translate("BaseWindow", "Bugs! Problems! Wishes!"))
|
self.actionBugs.setText(_translate("BaseWindow", "Bugs! Problems! Wishes!"))
|
||||||
self.actionShow_error_log.setText(_translate("BaseWindow", "Show error log"))
|
self.actionShow_error_log.setText(_translate("BaseWindow", "Show error log"))
|
||||||
self.actionCreate_starter.setText(_translate("BaseWindow", "Create starter.."))
|
self.actionCreate_starter.setText(_translate("BaseWindow", "Create starter.."))
|
||||||
@ -633,6 +624,5 @@ from ..data.point_select import PointSelectWidget
|
|||||||
from ..data.signaledit.editsignalwidget import EditSignalWidget
|
from ..data.signaledit.editsignalwidget import EditSignalWidget
|
||||||
from ..data.valueeditwidget import ValueEditWidget
|
from ..data.valueeditwidget import ValueEditWidget
|
||||||
from ..fit.fitwindow import QFitDialog
|
from ..fit.fitwindow import QFitDialog
|
||||||
from ..graphs.drawings import DrawingsWidget
|
|
||||||
from ..lib.mdiarea import MdiAreaTile
|
from ..lib.mdiarea import MdiAreaTile
|
||||||
from ..nmr.t1widget import QT1Widget
|
from ..nmr.t1widget import QT1Widget
|
||||||
|
@ -49,7 +49,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog):
|
|||||||
self._func_list = {}
|
self._func_list = {}
|
||||||
self._complex = {}
|
self._complex = {}
|
||||||
|
|
||||||
self.connected_figure = ''
|
self.connected_figure = None
|
||||||
|
|
||||||
self.model_frame.hide()
|
self.model_frame.hide()
|
||||||
self.preview_button.hide()
|
self.preview_button.hide()
|
||||||
|
@ -58,7 +58,7 @@ class RdBuCMap:
|
|||||||
elif val < self.min:
|
elif val < self.min:
|
||||||
col = QtGui.QColor.fromRgb(*RdBuCMap._rdbu[-1])
|
col = QtGui.QColor.fromRgb(*RdBuCMap._rdbu[-1])
|
||||||
else:
|
else:
|
||||||
col = QtGui.QColor.fromRgb(*(int(self.spline[i](val)) for i in range(3)))
|
col = QtGui.QColor.fromRgbF(*(float(self.spline[i](val)) for i in range(3)))
|
||||||
|
|
||||||
return col
|
return col
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ from numpy import geomspace, linspace
|
|||||||
from pyqtgraph import ViewBox
|
from pyqtgraph import ViewBox
|
||||||
|
|
||||||
from nmreval.configs import *
|
from nmreval.configs import *
|
||||||
|
from nmreval.lib.logger import logger
|
||||||
from nmreval.io.sessionwriter import NMRWriter
|
from nmreval.io.sessionwriter import NMRWriter
|
||||||
|
|
||||||
from .management import UpperManagement
|
from .management import UpperManagement
|
||||||
@ -128,7 +129,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
|
|
||||||
self.datawidget.management = self.management
|
self.datawidget.management = self.management
|
||||||
self.integralwidget.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 = QtWidgets.QActionGroup(self)
|
||||||
self.ac_group.addAction(self.action_lm_fit)
|
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.actionPick_position.triggered.connect(lambda: self._show_tab('pick'))
|
||||||
self.actionIntegration.triggered.connect(lambda: self._show_tab('integrate'))
|
self.actionIntegration.triggered.connect(lambda: self._show_tab('integrate'))
|
||||||
self.action_FitWidget.triggered.connect(lambda: self._show_tab('fit'))
|
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)
|
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.enable_picking(False)
|
||||||
|
|
||||||
self.current_graph_widget = None
|
self.current_graph_widget = None
|
||||||
self.management.current_graph = ''
|
self.management.current_graph = None
|
||||||
self.current_plotitem = None
|
self.current_plotitem = None
|
||||||
|
|
||||||
wdgt.setParent(None)
|
wdgt.setParent(None)
|
||||||
@ -493,7 +493,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
'signal': (self.editsignalwidget, 'Signals'),
|
'signal': (self.editsignalwidget, 'Signals'),
|
||||||
'pick': (self.ptsselectwidget, 'Pick points'),
|
'pick': (self.ptsselectwidget, 'Pick points'),
|
||||||
'fit': (self.fit_dialog, 'Fit'),
|
'fit': (self.fit_dialog, 'Fit'),
|
||||||
'drawing': (self.drawingswidget, 'Draw'),
|
|
||||||
'integrate': (self.integralwidget, 'Integrate'),
|
'integrate': (self.integralwidget, 'Integrate'),
|
||||||
}[mode]
|
}[mode]
|
||||||
|
|
||||||
@ -905,7 +904,9 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(dict, int, bool)
|
@QtCore.pyqtSlot(dict, int, bool)
|
||||||
def show_fit_preview(self, funcs: dict, num: int, show: 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
|
return
|
||||||
|
|
||||||
g = self.management.graphs[self.fit_dialog.connected_figure]
|
g = self.management.graphs[self.fit_dialog.connected_figure]
|
||||||
|
@ -110,7 +110,7 @@ class UpperManagement(QtCore.QObject):
|
|||||||
self.counter = 0
|
self.counter = 0
|
||||||
self.data = OrderedDict()
|
self.data = OrderedDict()
|
||||||
self.window = window
|
self.window = window
|
||||||
self.current_graph = ''
|
self.current_graph = None
|
||||||
self.graphs = GraphDict(self.data)
|
self.graphs = GraphDict(self.data)
|
||||||
self.namespace = None
|
self.namespace = None
|
||||||
self.undostack = QtWidgets.QUndoStack()
|
self.undostack = QtWidgets.QUndoStack()
|
||||||
@ -489,12 +489,14 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(list, bool)
|
@QtCore.pyqtSlot(list, bool)
|
||||||
def end_fit(self, result: list, success: bool):
|
def end_fit(self, result: list, success: bool):
|
||||||
logger.info('FIT FINISHED')
|
|
||||||
if success:
|
if success:
|
||||||
|
logger.info('Successful fit')
|
||||||
self.fitFinished.emit(result)
|
self.fitFinished.emit(result)
|
||||||
else:
|
else:
|
||||||
|
e = result[0]
|
||||||
|
logger.exception(e, exc_info=True)
|
||||||
QtWidgets.QMessageBox.warning(QtWidgets.QWidget(), 'Fit failed',
|
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.fitFinished.emit([])
|
||||||
self._fit_active = False
|
self._fit_active = False
|
||||||
|
|
||||||
@ -1213,6 +1215,6 @@ class FitWorker(QtCore.QObject):
|
|||||||
res = self.fitter.run(mode=self.mode)
|
res = self.fitter.run(mode=self.mode)
|
||||||
success = True
|
success = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = [e.args]
|
res = [e]
|
||||||
success = False
|
success = False
|
||||||
self.finished.emit(res, success)
|
self.finished.emit(res, success)
|
||||||
|
Loading…
Reference in New Issue
Block a user