From a3a75f5aee7c2d5ea8db0736841e767f9761f9c6 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 31 Jan 2024 16:53:19 +0100 Subject: [PATCH 1/2] fix index problem in smoothing dialog --- src/gui_qt/math/smooth.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gui_qt/math/smooth.py b/src/gui_qt/math/smooth.py index 387865d..d2ca5e7 100644 --- a/src/gui_qt/math/smooth.py +++ b/src/gui_qt/math/smooth.py @@ -12,10 +12,10 @@ class QSmooth(QtWidgets.QDialog, Ui_SmoothDialog): @QtCore.pyqtSlot(int, name='on_comboBox_currentIndexChanged') def change_mode(self, idx: int): - if idx == 2: + if idx == 1: self.widget.show() self.widget_2.hide() - elif idx == 3: + elif idx == 2: self.widget.show() self.widget_2.show() else: @@ -29,12 +29,24 @@ class QSmooth(QtWidgets.QDialog, Ui_SmoothDialog): idx = self.comboBox.currentIndex() # this order must match the combobox - para['mode'] = ['mean', 'savgol', 'loess', 'median', 'std', 'var', 'max', 'min', 'sum'][idx] + para['mode'] = [ + 'mean', + 'savgol', + 'loess', + 'median', + 'std', + 'var', + 'max', + 'min', + 'sum', + ][idx] - if idx == 2: + # Savitzky-Golay needs also polynomial degree + if idx == 1: para['deg'] = self.polynom_spinBox.value() - if idx == 3: + # LOESS needs also polynomial degree and number of iterations + if idx == 2: para['deg'] = self.polynom_spinBox.value() para['it'] = self.iter_spinBox.value() -- 2.39.5 From 11715af352574ffacd38abc134df61c1265e9103 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 31 Jan 2024 16:59:07 +0100 Subject: [PATCH 2/2] asciireader: make index in label consistent with selection --- src/nmreval/io/asciireader.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nmreval/io/asciireader.py b/src/nmreval/io/asciireader.py index e8c0b4f..05f84a5 100644 --- a/src/nmreval/io/asciireader.py +++ b/src/nmreval/io/asciireader.py @@ -183,7 +183,13 @@ class AsciiReader: single_len = 2 stepsize = 2 - cls = {'points': Points, 'fid': FID, 'spectrum': Spectrum, 'bds': BDS, 'dsc': DSC}[mode] + cls = { + 'points': Points, + 'fid': FID, + 'spectrum': Spectrum, + 'bds': BDS, + 'dsc': DSC, + }[mode] for j in range(1, num_y+1, stepsize): if col_names is not None: @@ -191,7 +197,7 @@ class AsciiReader: kwargs['name'] = col_names[j-1] elif num_y > single_len: # more than one axis, append column number - kwargs['name'] = filename + '_' + str(y[j-1]) + kwargs['name'] = f'{filename}_{y[j-1]+1}' if j+num_y < raw_data.shape[2]: kwargs['y_err'] = raw_data[i, :, j+num_y] -- 2.39.5