From ffba4900a18b15495f2c416d5342bba6c14ddabb Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 13 Feb 2024 16:17:08 +0000 Subject: [PATCH 1/2] remove complex kwarg when necessary (#246) closes #245 Co-authored-by: Dominik Demuth Reviewed-on: https://gitea.pkm.physik.tu-darmstadt.de/IPKM/nmreval/pulls/246 --- src/nmreval/fit/result.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nmreval/fit/result.py b/src/nmreval/fit/result.py index d77fd88..bd954b4 100644 --- a/src/nmreval/fit/result.py +++ b/src/nmreval/fit/result.py @@ -401,7 +401,10 @@ class FitResult(Points): raise ValueError('no fit function available to calculate new y values') new_fit = self.copy() - y_values = self.func.func(self.p_final, x_values, **self.fun_kwargs) + fun_kwargs = {k: v for k, v in self.fun_kwargs.items()} + if self.fun_kwargs.get('complex_mode', -1) == -1: + fun_kwargs.pop('complex_mode', None) + y_values = self.func.func(self.p_final, x_values, **fun_kwargs) y_values = check_complex(y_values, self.fun_kwargs.get('complex_mode', -1), self._data_complex) new_fit.set_data(x_values, y_values, y_err=0.0) @@ -414,6 +417,9 @@ class FitResult(Points): part_functions = [] actual_mode = self.fun_kwargs.get('complex_mode', -1) + fun_kwargs = {k: v for k, v in self.fun_kwargs.items()} + if self.fun_kwargs.get('complex_mode', -1) == -1: + fun_kwargs.pop('complex_mode', None) for sub_name, sub_y in zip(self.func.sub_name(), self.func.sub(self.p_final, x_values, **self.fun_kwargs)): sub_y = check_complex(sub_y, actual_mode, self._data_complex) From 04d384363ae59d2e951d35c937c9e65812a7093f Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 20 Feb 2024 16:19:23 +0000 Subject: [PATCH 2/2] 249-asciireader (#250) Co-authored-by: Dominik Demuth Reviewed-on: https://gitea.pkm.physik.tu-darmstadt.de/IPKM/nmreval/pulls/250 --- src/gui_qt/io/asciireader.py | 6 +++--- src/nmreval/io/asciireader.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py index a4c9524..2520844 100644 --- a/src/gui_qt/io/asciireader.py +++ b/src/gui_qt/io/asciireader.py @@ -38,7 +38,7 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): self.changestaggeredrange(0) self.ascii_table.contextMenuEvent = self.ctx_table - self.ascii_table.horizontalHeader().setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.ascii_table.horizontalHeader().setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.ascii_table.horizontalHeader().customContextMenuRequested.connect(self.ctx_table) self.skip = False @@ -65,7 +65,7 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): self.set_column_names(1) self.skippy_checkbox.blockSignals(True) - self.skippy_checkbox.setCheckState(QtCore.Qt.Unchecked) + self.skippy_checkbox.setCheckState(QtCore.Qt.CheckState.Unchecked) self.skippy_checkbox.blockSignals(False) return self @@ -232,7 +232,7 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): @QtCore.pyqtSlot(int, name='on_buttonGroup_buttonClicked') def show_error(self, val: int): - self.deltay_lineEdit.setEnabled(val == -3) + self.deltay_lineEdit.setEnabled(val == -2) @QtCore.pyqtSlot(int, name='on_skippy_checkbox_stateChanged') def skip_next_dial(self, _: int): diff --git a/src/nmreval/io/asciireader.py b/src/nmreval/io/asciireader.py index 05f84a5..6a31318 100644 --- a/src/nmreval/io/asciireader.py +++ b/src/nmreval/io/asciireader.py @@ -49,7 +49,7 @@ class AsciiReader: with self.fname.open('r') as f: for i, line in enumerate(islice(f, len(self.header)+len(self.lines), num_lines)): line = line.strip('\n\t\r, ') - line = re.sub(r'[\t ;,] *', ';', line) + line = re.sub(r'[\t ;,]+', ';', line) line = line.split(';') try: