From cb5d5b83b1eb8649050c75204a0de842981551a6 Mon Sep 17 00:00:00 2001 From: Silke Schomann Date: Mon, 19 May 2025 16:01:38 +0100 Subject: [PATCH 1/3] Catch oserror for ascii output --- src/mslice/models/workspacemanager/file_io.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mslice/models/workspacemanager/file_io.py b/src/mslice/models/workspacemanager/file_io.py index cdd20733..00af137c 100644 --- a/src/mslice/models/workspacemanager/file_io.py +++ b/src/mslice/models/workspacemanager/file_io.py @@ -270,9 +270,14 @@ def _get_slice_mdhisto_xye(histo_ws): def _output_data_to_ascii(output_path, out_data, header): - np.savetxt( - _to_absolute_path(str(output_path)), out_data, fmt="%12.9e", header=header - ) + try : + np.savetxt( + _to_absolute_path(str(output_path)), out_data, fmt="%12.9e", header=header + ) + except OSError as e: + raise RuntimeError( + f"Error occurred: {e}" + ) def _to_absolute_path(filepath: str) -> str: From 99a4bf9208d26267e2626da2df6e5fb2347326bb Mon Sep 17 00:00:00 2001 From: Silke Schomann Date: Mon, 19 May 2025 16:06:57 +0100 Subject: [PATCH 2/3] Remove temporary print --- src/mslice/util/mantid/algorithm_wrapper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mslice/util/mantid/algorithm_wrapper.py b/src/mslice/util/mantid/algorithm_wrapper.py index 61c982d6..1b7fa4f0 100644 --- a/src/mslice/util/mantid/algorithm_wrapper.py +++ b/src/mslice/util/mantid/algorithm_wrapper.py @@ -129,6 +129,5 @@ def remove_from_ads(workspacename): if AnalysisDataService.Instance().doesExist(hiddenworkspace): AnalysisDataService.Instance().remove(hiddenworkspace) hiddenworkspace = "__MSL" + workspacename + "_HIDDEN" - print(AnalysisDataService.Instance().getObjectNames()) if AnalysisDataService.Instance().doesExist(hiddenworkspace): AnalysisDataService.Instance().remove(hiddenworkspace) From 0d412308ec3fc0f7c21d3acd58030e9145bb5ca1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 15:18:00 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/mslice/models/workspacemanager/file_io.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mslice/models/workspacemanager/file_io.py b/src/mslice/models/workspacemanager/file_io.py index 00af137c..b5700a9d 100644 --- a/src/mslice/models/workspacemanager/file_io.py +++ b/src/mslice/models/workspacemanager/file_io.py @@ -270,14 +270,12 @@ def _get_slice_mdhisto_xye(histo_ws): def _output_data_to_ascii(output_path, out_data, header): - try : + try: np.savetxt( _to_absolute_path(str(output_path)), out_data, fmt="%12.9e", header=header - ) - except OSError as e: - raise RuntimeError( - f"Error occurred: {e}" ) + except OSError as e: + raise RuntimeError(f"Error occurred: {e}") def _to_absolute_path(filepath: str) -> str: