From e662dcf03c030ad9e0e49dd813ecb0280b5d7d9b Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 29 Nov 2023 19:16:58 +0100 Subject: [PATCH] add warning for non-working interpolations; fixes #159 --- src/gui_qt/main/management.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index 45fc02f..fb24633 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -829,9 +829,23 @@ class UpperManagement(QtCore.QObject): new_x = self.data[new_axis[0]].x new_key = [] + missed = [] for ids in data_ids: - k = self.add(interpolate(self.data[ids], new_x, xlog=xlog, ylog=ylog, kind=mode, extrapolate=True)) - new_key.append(k) + try: + k = self.add(interpolate(self.data[ids], new_x, xlog=xlog, ylog=ylog, kind=mode, extrapolate=True)) + new_key.append(k) + except ValueError: + missed.append(self.data[ids].name) + + if missed: + missed_str = '\n'.join(missed) + _ = QtWidgets.QMessageBox.warning( + QtWidgets.QWidget(), + 'Interpolation failed', + f'Interpolation failed for the following sets:\n\n' + f'{missed_str}\n\n' + f'(Probably because of duplicate x values)' + ) self.newData.emit(new_key, dest_graph)