run scripts
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m46s

run scripts

Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de>
Reviewed-on: #291
This commit is contained in:
2024-09-29 17:21:40 +00:00
parent b2a3881fa8
commit 4108deb69a
20 changed files with 401 additions and 229 deletions

View File

@ -1033,7 +1033,7 @@ class UpperManagement(QtCore.QObject):
else:
data = self.data[sets[0]]
if isinstance(data.data, new_type):
error_list.append(f'{data.name} is alreade of type {new_type.__name__}')
error_list.append(f'{data.name} is already of type {new_type.__name__}')
continue
new_data = new_type(data.x, np.zeros(data.x.size))
@ -1067,6 +1067,8 @@ class UpperManagement(QtCore.QObject):
@QtCore.pyqtSlot(list, list, bool)
def eval_expression(self, cmds: list, set_ids: list, overwrite: bool):
if self.namespace is None:
self.namespace = self.get_namespace()
ns = self.namespace.flatten()
if overwrite:
@ -1099,13 +1101,28 @@ class UpperManagement(QtCore.QObject):
if failures:
err_msg = QtWidgets.QMessageBox(parent=self.sender())
err_msg.setText('One or more errors occured during evaluation.')
err_msg.setText('One or more errors occurred during evaluation.')
err_msg.setDetailedText('\n'.join(f'{d.name} failed with error: {err.args}' for d, err in failures))
err_msg.exec()
self.sender().success = not failures
self.sender().add_data(self.active_sets)
@QtCore.pyqtSlot(str)
def run_script(self, text):
self.namespace = self.get_namespace()
ns = self.namespace.flatten()
ns['return_list'] = []
# custom namespace must be available in global namespace of exec, otherwise imports do not work in functions
exec(text, ns, ns)
new_sets = []
for new_data in ns['return_list']:
new_sets.append(self.add(new_data))
self.newData.emit(new_sets, '')
@QtCore.pyqtSlot(list, dict)
def create_from_function(self, cmds: list, opts: dict):
ns = dict(self.namespace.flatten())