bugfixes-022024 (#211)
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m30s

Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de>
Reviewed-on: #211
This commit is contained in:
Dominik Demuth 2024-01-11 12:39:03 +00:00
parent 73bdc71a83
commit d83e112515
4 changed files with 42 additions and 27 deletions

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'resources/_ui/fcreader.ui'
# Form implementation generated from reading ui file 'src/resources/_ui/fcreader.ui'
#
# Created by: PyQt5 UI code generator 5.12.3
# Created by: PyQt5 UI code generator 5.15.10
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
@ -47,6 +48,7 @@ class Ui_FCEval_dialog(object):
self.verticalLayout.addWidget(self.input_box)
self.region_box = QtWidgets.QGroupBox(FCEval_dialog)
self.region_box.setCheckable(True)
self.region_box.setChecked(False)
self.region_box.setObjectName("region_box")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.region_box)
self.horizontalLayout.setContentsMargins(3, 3, 3, 3)
@ -139,6 +141,7 @@ class Ui_FCEval_dialog(object):
self.line.setObjectName("line")
self.gridLayout.addWidget(self.line, 2, 0, 1, 2)
self.graph_comboBox = QtWidgets.QComboBox(self.out_box)
self.graph_comboBox.setEnabled(False)
self.graph_comboBox.setObjectName("graph_comboBox")
self.gridLayout.addWidget(self.graph_comboBox, 3, 1, 1, 1)
self.graph_checkbox = QtWidgets.QCheckBox(self.out_box)
@ -167,8 +170,8 @@ class Ui_FCEval_dialog(object):
self.label_6.setBuddy(self.m0_cb)
self.retranslateUi(FCEval_dialog)
self.buttonBox.accepted.connect(FCEval_dialog.accept)
self.buttonBox.rejected.connect(FCEval_dialog.reject)
self.buttonBox.accepted.connect(FCEval_dialog.accept) # type: ignore
self.buttonBox.rejected.connect(FCEval_dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(FCEval_dialog)
def retranslateUi(self, FCEval_dialog):
@ -178,7 +181,7 @@ class Ui_FCEval_dialog(object):
self.file_pushbutton.setText(_translate("FCEval_dialog", "Add HDF files..."))
self.dir_pushbutton.setText(_translate("FCEval_dialog", "Add directory..."))
self.overwrite_cb.setText(_translate("FCEval_dialog", "Overwrite prev. data"))
self.region_box.setTitle(_translate("FCEval_dialog", "Evaluate region (empty values default to start/end)"))
self.region_box.setTitle(_translate("FCEval_dialog", "Evaluate region (empty values default to values of the script)"))
self.start_lineedit.setPlaceholderText(_translate("FCEval_dialog", "start pos in µs"))
self.stop_lineedit.setPlaceholderText(_translate("FCEval_dialog", "end pos in µs"))
self.fit_box.setTitle(_translate("FCEval_dialog", "Fit equation"))

View File

@ -229,20 +229,16 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
self.fit_plot.enableAutoRange()
def _plot_residuals(self, idx: str = None):
print(idx)
if idx is None or isinstance(idx, QtWidgets.QAbstractButton):
idx = self.sets_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole)
res = self._results[idx]
if res.iscomplex:
if self.rel_dev_button.isChecked():
print('rel')
self.resid_graph.setData(x=res.x_data, y=res.residual.real/np_abs(res.y_data.real))
print(res.y_data.imag)
if all(np_isfinite(res.y_data.imag)):
self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag/np_abs(res.y_data.imag))
else:
print('abs')
self.resid_graph.setData(x=res.x_data, y=res.residual.real)
self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag)

View File

@ -22,14 +22,16 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
self.start_lineedit.setValidator(QtGui.QDoubleValidator())
self.stop_lineedit.setValidator(QtGui.QDoubleValidator())
self.graph_checkbox.stateChanged.connect(lambda x: self.graph_comboBox.setEnabled(not bool(x)))
self.graph_checkbox.stateChanged.connect(
lambda x: self.graph_comboBox.setEnabled(x == QtCore.Qt.CheckState.Unchecked)
)
self.listWidget.installEventFilter(self)
def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool:
# intercept key press in listwidget to allow deletion with Del
if evt.type() == QtCore.QEvent.KeyPress:
if evt.key() == QtCore.Qt.Key_Delete:
if evt.type() == QtCore.QEvent.Type.KeyPress:
if evt.key() == QtCore.Qt.Key.Key_Delete:
self.listWidget.takeItem(self.listWidget.currentRow())
return True
@ -41,21 +43,25 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
@QtCore.pyqtSlot(int, name='on_region_checkBox_stateChanged')
def use_region(self, state: int):
self.start_lineedit.setEnabled(state == QtCore.Qt.Checked)
self.stop_lineedit.setEnabled(state == QtCore.Qt.Checked)
self.start_lineedit.setEnabled(state == QtCore.Qt.CheckState.Checked)
self.stop_lineedit.setEnabled(state == QtCore.Qt.CheckState.Checked)
@QtCore.pyqtSlot(name='on_file_pushbutton_clicked')
@QtCore.pyqtSlot(name='on_dir_pushbutton_clicked')
def get_input(self):
if self.sender() == self.file_pushbutton:
infiles, _ = QtWidgets.QFileDialog.getOpenFileNames(caption='Select HDF files',
directory=str(self.path),
filter='HDF files (*.h5)')
infiles, _ = QtWidgets.QFileDialog.getOpenFileNames(
caption='Select HDF files',
directory=str(self.path),
filter='HDF files (*.h5)',
)
else:
infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory',
directory=str(self.path),
options=QtWidgets.QFileDialog.ShowDirsOnly)
infiles = QtWidgets.QFileDialog.getExistingDirectory(
caption='Select input directory',
directory=str(self.path),
options=QtWidgets.QFileDialog.ShowDirsOnly,
)
infiles = [infiles] if infiles else infiles
if infiles:
@ -65,9 +71,12 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
@QtCore.pyqtSlot(name='on_savebutton_clicked')
def save_path(self):
outfile = QtWidgets.QFileDialog.getExistingDirectory(self, caption='Select directory',
directory=self.label.text(),
options=QtWidgets.QFileDialog.ShowDirsOnly)
outfile = QtWidgets.QFileDialog.getExistingDirectory(
self,
caption='Select directory',
directory=self.label.text(),
options=QtWidgets.QFileDialog.ShowDirsOnly,
)
if outfile:
self.label.setText(outfile)
@ -110,6 +119,6 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
grp = ''
if not self.graph_checkbox.isChecked():
grp = self.graph_comboBox.currentData(QtCore.Qt.UserRole)
grp = self.graph_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole)
self.data_read.emit(ret_vals, grp)

View File

@ -96,11 +96,14 @@
<item>
<widget class="QGroupBox" name="region_box">
<property name="title">
<string>Evaluate region (empty values default to start/end)</string>
<string>Evaluate region (empty values default to values of the script)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
@ -311,7 +314,11 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="graph_comboBox"/>
<widget class="QComboBox" name="graph_comboBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="graph_checkbox">