From 0fccc9c5faf3cfcc7494cd82ce9cff162ced68ce Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Tue, 6 Oct 2026 15:18:26 +0100 Subject: [PATCH 01/13] remove 1/2 factor in `window_wf_check` --- packs/ana/analysis_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packs/ana/analysis_utils.py b/packs/ana/analysis_utils.py index b7d1dd3..3e63137 100644 --- a/packs/ana/analysis_utils.py +++ b/packs/ana/analysis_utils.py @@ -290,7 +290,7 @@ def window_wf_check(wf : np.ndarray, BASELINE_POINT_2 = window_args['BASELINE_POINT_2'] BASELINE_RANGE_1 = window_args['BASELINE_RANGE_1'] BASELINE_RANGE_2 = window_args['BASELINE_RANGE_2'] - if WINDOW_START>length or WINDOW_END>length or BASELINE_POINT_1+BASELINE_RANGE_1/2>length or BASELINE_POINT_2+BASELINE_RANGE_2>length: + if WINDOW_START>length or WINDOW_END>length or BASELINE_POINT_1+BASELINE_RANGE_1>length or BASELINE_POINT_2+BASELINE_RANGE_2>length: return False else: return True \ No newline at end of file From bfc77d40193680c7ef1918eb495d816a70e33a49 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Tue, 6 Oct 2026 15:21:23 +0100 Subject: [PATCH 02/13] remove more incorrect 1/2s in `window_overlap_check` --- packs/ana/analysis_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packs/ana/analysis_utils.py b/packs/ana/analysis_utils.py index 3e63137..9663296 100644 --- a/packs/ana/analysis_utils.py +++ b/packs/ana/analysis_utils.py @@ -245,11 +245,11 @@ def window_overlap_check(window_args: dict): # Define intervals w_start, w_end = WINDOW_START, WINDOW_END - b1_start = BASELINE_POINT_1 - BASELINE_RANGE_1 / 2 - b1_end = BASELINE_POINT_1 + BASELINE_RANGE_1 / 2 + b1_start = BASELINE_POINT_1 - BASELINE_RANGE_1 + b1_end = BASELINE_POINT_1 + BASELINE_RANGE_1 - b2_start = BASELINE_POINT_2 - BASELINE_RANGE_2 / 2 - b2_end = BASELINE_POINT_2 + BASELINE_RANGE_2 / 2 + b2_start = BASELINE_POINT_2 - BASELINE_RANGE_2 + b2_end = BASELINE_POINT_2 + BASELINE_RANGE_2 # Check for negative values if (w_start < 0 or w_end < 0 or From fbbabbb7ccf3167a1268cd282b04b5c3f7a46bb4 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Tue, 6 Oct 2026 16:09:01 +0100 Subject: [PATCH 03/13] create test configs --- .../data/configs/ana_bad_baseline_mode.conf | 21 +++++++++++++++++ .../configs/ana_baseline_overlaps_window.conf | 21 +++++++++++++++++ .../data/configs/ana_baselines_overlap.conf | 21 +++++++++++++++++ packs/tests/data/configs/ana_empty_files.conf | 21 +++++++++++++++++ .../data/configs/ana_inverted_window.conf | 21 +++++++++++++++++ .../data/configs/ana_missing_bin_size.conf | 21 +++++++++++++++++ .../data/configs/ana_missing_save_path.conf | 20 ++++++++++++++++ .../data/configs/ana_missing_window_args.conf | 16 +++++++++++++ .../data/configs/ana_missing_window_key.conf | 20 ++++++++++++++++ .../data/configs/ana_negative_window.conf | 21 +++++++++++++++++ .../data/configs/ana_nonexistent_file.conf | 21 +++++++++++++++++ .../data/configs/ana_save_dir_missing.conf | 21 +++++++++++++++++ packs/tests/data/configs/ana_unkown_key.conf | 23 +++++++++++++++++++ 13 files changed, 268 insertions(+) create mode 100644 packs/tests/data/configs/ana_bad_baseline_mode.conf create mode 100644 packs/tests/data/configs/ana_baseline_overlaps_window.conf create mode 100644 packs/tests/data/configs/ana_baselines_overlap.conf create mode 100644 packs/tests/data/configs/ana_empty_files.conf create mode 100644 packs/tests/data/configs/ana_inverted_window.conf create mode 100644 packs/tests/data/configs/ana_missing_bin_size.conf create mode 100644 packs/tests/data/configs/ana_missing_save_path.conf create mode 100644 packs/tests/data/configs/ana_missing_window_args.conf create mode 100644 packs/tests/data/configs/ana_missing_window_key.conf create mode 100644 packs/tests/data/configs/ana_negative_window.conf create mode 100644 packs/tests/data/configs/ana_nonexistent_file.conf create mode 100644 packs/tests/data/configs/ana_save_dir_missing.conf create mode 100644 packs/tests/data/configs/ana_unkown_key.conf diff --git a/packs/tests/data/configs/ana_bad_baseline_mode.conf b/packs/tests/data/configs/ana_bad_baseline_mode.conf new file mode 100644 index 0000000..3c0b1b8 --- /dev/null +++ b/packs/tests/data/configs/ana_bad_baseline_mode.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'three hundred baselines please' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_baseline_overlaps_window.conf b/packs/tests/data/configs/ana_baseline_overlaps_window.conf new file mode 100644 index 0000000..75ff162 --- /dev/null +++ b/packs/tests/data/configs/ana_baseline_overlaps_window.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : 4e2, + 'WINDOW_END' : 2e6, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_baselines_overlap.conf b/packs/tests/data/configs/ana_baselines_overlap.conf new file mode 100644 index 0000000..7479255 --- /dev/null +++ b/packs/tests/data/configs/ana_baselines_overlap.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.01e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_empty_files.conf b/packs/tests/data/configs/ana_empty_files.conf new file mode 100644 index 0000000..0eb49f8 --- /dev/null +++ b/packs/tests/data/configs/ana_empty_files.conf @@ -0,0 +1,21 @@ +[required] + +files = [''] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_inverted_window.conf b/packs/tests/data/configs/ana_inverted_window.conf new file mode 100644 index 0000000..a2c00e0 --- /dev/null +++ b/packs/tests/data/configs/ana_inverted_window.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : 3e4, + 'WINDOW_END' : 4e2, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_missing_bin_size.conf b/packs/tests/data/configs/ana_missing_bin_size.conf new file mode 100644 index 0000000..e54e9b2 --- /dev/null +++ b/packs/tests/data/configs/ana_missing_bin_size.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + + +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_missing_save_path.conf b/packs/tests/data/configs/ana_missing_save_path.conf new file mode 100644 index 0000000..81dc720 --- /dev/null +++ b/packs/tests/data/configs/ana_missing_save_path.conf @@ -0,0 +1,20 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True diff --git a/packs/tests/data/configs/ana_missing_window_args.conf b/packs/tests/data/configs/ana_missing_window_args.conf new file mode 100644 index 0000000..9521d13 --- /dev/null +++ b/packs/tests/data/configs/ana_missing_window_args.conf @@ -0,0 +1,16 @@ +[required] + +files = ['run19.h5'] + + + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_missing_window_key.conf b/packs/tests/data/configs/ana_missing_window_key.conf new file mode 100644 index 0000000..54a8241 --- /dev/null +++ b/packs/tests/data/configs/ana_missing_window_key.conf @@ -0,0 +1,20 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_negative_window.conf b/packs/tests/data/configs/ana_negative_window.conf new file mode 100644 index 0000000..d7831f4 --- /dev/null +++ b/packs/tests/data/configs/ana_negative_window.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_nonexistent_file.conf b/packs/tests/data/configs/ana_nonexistent_file.conf new file mode 100644 index 0000000..6e4958f --- /dev/null +++ b/packs/tests/data/configs/ana_nonexistent_file.conf @@ -0,0 +1,21 @@ +[required] + +files = ['secretfakefile.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_save_dir_missing.conf b/packs/tests/data/configs/ana_save_dir_missing.conf new file mode 100644 index 0000000..8bde23a --- /dev/null +++ b/packs/tests/data/configs/ana_save_dir_missing.conf @@ -0,0 +1,21 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'nosuchthing/test.h5' \ No newline at end of file diff --git a/packs/tests/data/configs/ana_unkown_key.conf b/packs/tests/data/configs/ana_unkown_key.conf new file mode 100644 index 0000000..191ef33 --- /dev/null +++ b/packs/tests/data/configs/ana_unkown_key.conf @@ -0,0 +1,23 @@ +[required] + +files = ['run19.h5'] + +window_args = {'WINDOW_START' : -100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' + +mules = 'bad' \ No newline at end of file From a77aa3fdeef37c1a20b100dff6e9eb7f802a2c82 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Tue, 6 Oct 2026 16:09:13 +0100 Subject: [PATCH 04/13] write config setup test --- packs/tests/setup_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packs/tests/setup_test.py b/packs/tests/setup_test.py index 5901862..3256e73 100644 --- a/packs/tests/setup_test.py +++ b/packs/tests/setup_test.py @@ -70,3 +70,24 @@ def test_processing_catches(config, error, MULE_dir, data_dir): subprocess.run(run_pack, check = True) +@mark.parametrize("config, error", [('ana_negative_window.conf', ValueError), + ('ana_inverted_window.conf', ValueError), + ('ana_baseline_overlaps_window.conf', ValueError), + ('ana_baselines_overlap.conf', ValueError), + ('ana_missing_window_key.conf', KeyError), + ('ana_missing_window_args.conf', KeyError), + ('ana_missing_save_path.conf', KeyError), + ('ana_missing_bin_size.conf', TypeError), + ('ana_unknown_key.conf', TypeError), + ('ana_nonexistent_file.conf', ValueError), + ('ana_empty_files.conf', ValueError), + ('ana_bad_baseline_mode.conf', ValueError), + ('ana_save_dir_missing.conf', FileNotFoundError)]) +def test_ana_catches(config, error, MULE_dir, data_dir): + + config_path = data_dir + "configs/" + config + + run_pack = [sys.executable, MULE_dir + "/bin/mule", "ana", config_path] + + with raises(subprocess.CalledProcessError): + subprocess.run(run_pack, check = True) \ No newline at end of file From 8b31bce5fb11c829c83f2c7a319fa3388984f8e2 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 09:25:58 +0100 Subject: [PATCH 05/13] make the test check for error type --- packs/tests/setup_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packs/tests/setup_test.py b/packs/tests/setup_test.py index 3256e73..5894dcc 100644 --- a/packs/tests/setup_test.py +++ b/packs/tests/setup_test.py @@ -89,5 +89,7 @@ def test_ana_catches(config, error, MULE_dir, data_dir): run_pack = [sys.executable, MULE_dir + "/bin/mule", "ana", config_path] - with raises(subprocess.CalledProcessError): - subprocess.run(run_pack, check = True) \ No newline at end of file + with raises(subprocess.CalledProcessError) as excinfo: + subprocess.run(run_pack, check=True, capture_output=True, text=True) + assert error.__name__ in excinfo.value.stderr + \ No newline at end of file From 932c7fc69d2be48361311cc57bc11192df3f8c83 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 09:31:13 +0100 Subject: [PATCH 06/13] fix test config typos --- packs/tests/data/configs/ana_bad_baseline_mode.conf | 2 +- packs/tests/data/configs/ana_baselines_overlap.conf | 2 +- packs/tests/data/configs/ana_empty_files.conf | 2 +- packs/tests/data/configs/ana_missing_bin_size.conf | 2 +- packs/tests/data/configs/ana_missing_save_path.conf | 2 +- packs/tests/data/configs/ana_missing_window_key.conf | 2 +- packs/tests/data/configs/ana_nonexistent_file.conf | 2 +- packs/tests/data/configs/ana_save_dir_missing.conf | 2 +- .../data/configs/{ana_unkown_key.conf => ana_unknown_key.conf} | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) rename packs/tests/data/configs/{ana_unkown_key.conf => ana_unknown_key.conf} (90%) diff --git a/packs/tests/data/configs/ana_bad_baseline_mode.conf b/packs/tests/data/configs/ana_bad_baseline_mode.conf index 3c0b1b8..0b13cc8 100644 --- a/packs/tests/data/configs/ana_bad_baseline_mode.conf +++ b/packs/tests/data/configs/ana_bad_baseline_mode.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_baselines_overlap.conf b/packs/tests/data/configs/ana_baselines_overlap.conf index 7479255..51f838d 100644 --- a/packs/tests/data/configs/ana_baselines_overlap.conf +++ b/packs/tests/data/configs/ana_baselines_overlap.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.01e6, diff --git a/packs/tests/data/configs/ana_empty_files.conf b/packs/tests/data/configs/ana_empty_files.conf index 0eb49f8..e221fce 100644 --- a/packs/tests/data/configs/ana_empty_files.conf +++ b/packs/tests/data/configs/ana_empty_files.conf @@ -2,7 +2,7 @@ files = [''] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_missing_bin_size.conf b/packs/tests/data/configs/ana_missing_bin_size.conf index e54e9b2..5c60469 100644 --- a/packs/tests/data/configs/ana_missing_bin_size.conf +++ b/packs/tests/data/configs/ana_missing_bin_size.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_missing_save_path.conf b/packs/tests/data/configs/ana_missing_save_path.conf index 81dc720..7254d28 100644 --- a/packs/tests/data/configs/ana_missing_save_path.conf +++ b/packs/tests/data/configs/ana_missing_save_path.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_missing_window_key.conf b/packs/tests/data/configs/ana_missing_window_key.conf index 54a8241..b3f1bee 100644 --- a/packs/tests/data/configs/ana_missing_window_key.conf +++ b/packs/tests/data/configs/ana_missing_window_key.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_nonexistent_file.conf b/packs/tests/data/configs/ana_nonexistent_file.conf index 6e4958f..f5ad75d 100644 --- a/packs/tests/data/configs/ana_nonexistent_file.conf +++ b/packs/tests/data/configs/ana_nonexistent_file.conf @@ -2,7 +2,7 @@ files = ['secretfakefile.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_save_dir_missing.conf b/packs/tests/data/configs/ana_save_dir_missing.conf index 8bde23a..4e39285 100644 --- a/packs/tests/data/configs/ana_save_dir_missing.conf +++ b/packs/tests/data/configs/ana_save_dir_missing.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, diff --git a/packs/tests/data/configs/ana_unkown_key.conf b/packs/tests/data/configs/ana_unknown_key.conf similarity index 90% rename from packs/tests/data/configs/ana_unkown_key.conf rename to packs/tests/data/configs/ana_unknown_key.conf index 191ef33..25fc11a 100644 --- a/packs/tests/data/configs/ana_unkown_key.conf +++ b/packs/tests/data/configs/ana_unknown_key.conf @@ -2,7 +2,7 @@ files = ['run19.h5'] -window_args = {'WINDOW_START' : -100, +window_args = {'WINDOW_START' : 100, 'WINDOW_END' : 3e4, 'BASELINE_POINT_1' : 1e6, 'BASELINE_POINT_2' : 1.5e6, From 19e9c9ee08765803b650cb60b98907b4c9478024 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 09:34:05 +0100 Subject: [PATCH 07/13] check save path exists before averaging to catch errors sooner --- packs/ana/ana.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packs/ana/ana.py b/packs/ana/ana.py index fb49325..74addae 100644 --- a/packs/ana/ana.py +++ b/packs/ana/ana.py @@ -23,13 +23,13 @@ def ana(config_file : str) -> (np.ndarray): if isinstance(conf_args["files"], list): print("Averaging waveform....") - avgwf = average_waveforms(**conf_args) - checked_save_path = check_save_path( save_path, overwrite ) + avgwf = average_waveforms(**conf_args) + with h5py.File(checked_save_path, 'w') as f: # Save as a h5 f.create_dataset('Average_waveform', data=avgwf) From 31c45943d32f678e20aec14d29dbc28941f0a5d6 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 09:38:01 +0100 Subject: [PATCH 08/13] non list of files return TypeError for config error catching --- packs/ana/ana.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packs/ana/ana.py b/packs/ana/ana.py index 74addae..7babf1b 100644 --- a/packs/ana/ana.py +++ b/packs/ana/ana.py @@ -20,21 +20,22 @@ def ana(config_file : str) -> (np.ndarray): window_overlap_check(window_args) - if isinstance(conf_args["files"], list): - print("Averaging waveform....") - - checked_save_path = check_save_path( - save_path, - overwrite + if not isinstance(conf_args["files"], list): + raise TypeError( + f"'files' must be a list of file paths, got {type(conf_args['files']).__name__}" ) + print("Averaging waveform....") + + checked_save_path = check_save_path( + save_path, + overwrite + ) - avgwf = average_waveforms(**conf_args) + avgwf = average_waveforms(**conf_args) - with h5py.File(checked_save_path, 'w') as f: # Save as a h5 - f.create_dataset('Average_waveform', data=avgwf) + with h5py.File(checked_save_path, 'w') as f: # Save as a h5 + f.create_dataset('Average_waveform', data=avgwf) - print(f"Saved to: {checked_save_path}") + print(f"Saved to: {checked_save_path}") - else: - print("Please input files as a list.") return \ No newline at end of file From 8699e87a58bcb08d478cb70902be60899877825f Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 09:44:23 +0100 Subject: [PATCH 09/13] config for files not given in a list --- .../data/configs/ana_files_not_list.conf | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packs/tests/data/configs/ana_files_not_list.conf diff --git a/packs/tests/data/configs/ana_files_not_list.conf b/packs/tests/data/configs/ana_files_not_list.conf new file mode 100644 index 0000000..60d3ba4 --- /dev/null +++ b/packs/tests/data/configs/ana_files_not_list.conf @@ -0,0 +1,21 @@ +[required] + +files = 'run19.h5' + +window_args = {'WINDOW_START' : 100, + 'WINDOW_END' : 3e4, + 'BASELINE_POINT_1' : 1e6, + 'BASELINE_POINT_2' : 1.5e6, + 'BASELINE_RANGE_1' : 40e3, + 'BASELINE_RANGE_2' : 40e3} + +bin_size = 4 +chunk_size = 5 +negative = True +baseline_mode = 'median' +verbose = 1 +peak_threshold = 1000 +suppression_threshold = 10 + +overwrite = True +save_path = 'test.h5' \ No newline at end of file From 1c3a5de284c70b232256b4790cde03bfbb637b0d Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 09:44:37 +0100 Subject: [PATCH 10/13] add test for files not given in a list --- packs/tests/setup_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packs/tests/setup_test.py b/packs/tests/setup_test.py index 5894dcc..e21d11c 100644 --- a/packs/tests/setup_test.py +++ b/packs/tests/setup_test.py @@ -82,7 +82,8 @@ def test_processing_catches(config, error, MULE_dir, data_dir): ('ana_nonexistent_file.conf', ValueError), ('ana_empty_files.conf', ValueError), ('ana_bad_baseline_mode.conf', ValueError), - ('ana_save_dir_missing.conf', FileNotFoundError)]) + ('ana_save_dir_missing.conf', FileNotFoundError), + ('ana_files_not_list.conf', TypeError)]) def test_ana_catches(config, error, MULE_dir, data_dir): config_path = data_dir + "configs/" + config From 4b458037b01368b0dfd9bbf2282605858f1f2383 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 13:38:47 +0100 Subject: [PATCH 11/13] improve `test_processing_catches` To look for specific errors --- packs/tests/setup_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packs/tests/setup_test.py b/packs/tests/setup_test.py index e21d11c..5b1935d 100644 --- a/packs/tests/setup_test.py +++ b/packs/tests/setup_test.py @@ -56,7 +56,7 @@ def test_malformed_config(config, error, data_dir): x = read_config_file(file_path) @mark.parametrize("config, error", [('nonexistent_WD_version.conf', RuntimeError), - ('nonexistent_process.conf', ValueError), + ('nonexistent_process.conf', RuntimeError), ('single_multi_chan.conf', RuntimeError)]) # these will change to value errors when other # packs are implemented @@ -66,8 +66,9 @@ def test_processing_catches(config, error, MULE_dir, data_dir): run_pack = [sys.executable, MULE_dir + "/bin/mule", "proc", config_path] - with raises(subprocess.CalledProcessError): - subprocess.run(run_pack, check = True) + with raises(subprocess.CalledProcessError) as excinfo: + subprocess.run(run_pack, check=True, capture_output=True, text=True) + assert error.__name__ in excinfo.value.stderr @mark.parametrize("config, error", [('ana_negative_window.conf', ValueError), From 910b6f5ae99b124966c8305c3321da05f5f77be1 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 13:46:42 +0100 Subject: [PATCH 12/13] use abspath for save paths small bug fix in `check_save_path` in proc, similar to one used in ana --- packs/proc/processing_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index 5b41059..9cc48af 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -420,8 +420,9 @@ def check_save_path(save_path: str, ------ FileNotFoundError : If the directory of save_path does not exist ''' - if not os.path.exists(os.path.dirname(save_path)): - raise FileNotFoundError(2, 'Save path not found', os.path.dirname(save_path)) + dirname = os.path.dirname(os.path.abspath(save_path)) + if not os.path.exists(dirname): + raise FileNotFoundError(2, 'Save path not found', dirname) if overwrite: return save_path From 65f9d8856049a530f3cf95b3dff27470ab95c832 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Wed, 7 Oct 2026 13:49:24 +0100 Subject: [PATCH 13/13] Run proc catch tests from test data directory --- packs/tests/setup_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packs/tests/setup_test.py b/packs/tests/setup_test.py index 5b1935d..d7a54eb 100644 --- a/packs/tests/setup_test.py +++ b/packs/tests/setup_test.py @@ -67,7 +67,7 @@ def test_processing_catches(config, error, MULE_dir, data_dir): run_pack = [sys.executable, MULE_dir + "/bin/mule", "proc", config_path] with raises(subprocess.CalledProcessError) as excinfo: - subprocess.run(run_pack, check=True, capture_output=True, text=True) + subprocess.run(run_pack, check=True, capture_output=True, text=True, cwd = data_dir) assert error.__name__ in excinfo.value.stderr