From ac9dc52d219ac8d953f765457e260277539478db Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Sat, 27 Apr 2024 16:44:59 -0400 Subject: [PATCH 1/5] fix pre-commit erroneous errors Signed-off-by: Jose Borreguero --- .../sf_calculator/reduction_sf_calculator.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/RefRed/sf_calculator/reduction_sf_calculator.py b/RefRed/sf_calculator/reduction_sf_calculator.py index 5649325a..10e1e27b 100644 --- a/RefRed/sf_calculator/reduction_sf_calculator.py +++ b/RefRed/sf_calculator/reduction_sf_calculator.py @@ -205,21 +205,21 @@ def generate_script( script += "from lr_reduction.scaling_factors import LRScalingFactors\n" script += "from lr_reduction.utils import mantid_algorithm_exec\n\n" - script += "mantid_algorithm_exec(\n" - script += " LRScalingFactors.LRScalingFactors,\n" - script += f" DirectBeamRuns={run_list},\n" - script += f" IncidentMedium='{incident_medium}',\n" - script += f" TOFRange={tof_range},\n" - script += f" TOFSteps={self.sf_gui.deadtime_tof_step},\n" - script += f" SignalPeakPixelRange={peak_ranges},\n" - script += f" SignalBackgroundPixelRange={bck_ranges},\n" - script += f" LowResolutionPixelRange={low_res_ranges},\n" - script += f" ScalingFactorFile='{output_file_name}',\n" - script += f" UseDeadTimeCorrection={self.sf_gui.apply_deadtime},\n" - script += f" ParalyzableDeadTime={self.sf_gui.paralyzable_deadtime},\n" - script += f" DeadTime={self.sf_gui.deadtime_value},\n" - script += f" DeadTimeTOFStep={self.sf_gui.deadtime_tof_step},\n" - script += ")\n" + script += r'mantid_algorithm_exec(\n' + script += r' LRScalingFactors.LRScalingFactors,\n' + script += r' DirectBeamRuns={0},\n'.format(run_list) + script += r' IncidentMedium="{0}",\n'.format(incident_medium) + script += r' TOFRange={0},\n'.format(tof_range) + script += r' TOFSteps={0},\n'.format(self.sf_gui.deadtime_tof_step) + script += r' SignalPeakPixelRange={0},\n'.format(peak_ranges) + script += r' SignalBackgroundPixelRange={0},\n'.format(bck_ranges) + script += r' LowResolutionPixelRange={0},\n'.format(low_res_ranges) + script += r' ScalingFactorFile="{0}",\n'.format(output_file_name) + script += r' UseDeadTimeCorrection={0},\n'.format(self.sf_gui.apply_deadtime) + script += r' ParalyzableDeadTime={0},\n'.format(self.sf_gui.paralyzable_deadtime) + script += r' DeadTime={0},\n'.format(self.sf_gui.deadtime_value) + script += r' DeadTimeTOFStep={0},\n'.format(self.sf_gui.deadtime_tof_step) + script += r')\n' return script From d062df00fb7360495427ff83f41517afed54d487 Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Sat, 27 Apr 2024 16:50:40 -0400 Subject: [PATCH 2/5] ignore flake8 error Signed-off-by: Jose Borreguero --- test/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 087495c6..b8d7f0d0 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -35,8 +35,8 @@ def directory(self): def path_to(self, basename): r"""Absolute path to a data file""" file_path = os.path.join(self._directory, basename) - if not os.path.isfile(file_path): - raise IOError(f'File {basename} not found in data directory {self._directory}') + if os.path.isfile(file_path) is False: + raise FileNotFoundError(f"File {basename} not found in data directory {self._directory}") # noqa E713 return file_path yield _DataServe() From 772fd3793731480f7b3fe32c344bbc40f9586860 Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Sat, 27 Apr 2024 17:24:19 -0400 Subject: [PATCH 3/5] fix test Signed-off-by: Jose Borreguero --- .../sf_calculator/reduction_sf_calculator.py | 33 ++++++++++--------- test/ui/test_compute_scaling_factors.py | 5 +-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/RefRed/sf_calculator/reduction_sf_calculator.py b/RefRed/sf_calculator/reduction_sf_calculator.py index 10e1e27b..f785ea3a 100644 --- a/RefRed/sf_calculator/reduction_sf_calculator.py +++ b/RefRed/sf_calculator/reduction_sf_calculator.py @@ -205,22 +205,23 @@ def generate_script( script += "from lr_reduction.scaling_factors import LRScalingFactors\n" script += "from lr_reduction.utils import mantid_algorithm_exec\n\n" - script += r'mantid_algorithm_exec(\n' - script += r' LRScalingFactors.LRScalingFactors,\n' - script += r' DirectBeamRuns={0},\n'.format(run_list) - script += r' IncidentMedium="{0}",\n'.format(incident_medium) - script += r' TOFRange={0},\n'.format(tof_range) - script += r' TOFSteps={0},\n'.format(self.sf_gui.deadtime_tof_step) - script += r' SignalPeakPixelRange={0},\n'.format(peak_ranges) - script += r' SignalBackgroundPixelRange={0},\n'.format(bck_ranges) - script += r' LowResolutionPixelRange={0},\n'.format(low_res_ranges) - script += r' ScalingFactorFile="{0}",\n'.format(output_file_name) - script += r' UseDeadTimeCorrection={0},\n'.format(self.sf_gui.apply_deadtime) - script += r' ParalyzableDeadTime={0},\n'.format(self.sf_gui.paralyzable_deadtime) - script += r' DeadTime={0},\n'.format(self.sf_gui.deadtime_value) - script += r' DeadTimeTOFStep={0},\n'.format(self.sf_gui.deadtime_tof_step) - script += r')\n' - + mantid_call = [r"mantid_algorithm_exec(", + r" LRScalingFactors.LRScalingFactors,", + r" DirectBeamRuns={0},".format(run_list), + r" IncidentMedium='{0}',".format(incident_medium), + r" TOFRange={0},".format(tof_range), + r" TOFSteps={0},".format(self.sf_gui.deadtime_tof_step), + r" SignalPeakPixelRange={0},".format(peak_ranges), + r" SignalBackgroundPixelRange={0},".format(bck_ranges), + r" LowResolutionPixelRange={0},".format(low_res_ranges), + r" ScalingFactorFile='{0}',".format(output_file_name), + r" UseDeadTimeCorrection={0},".format(self.sf_gui.apply_deadtime), + r" ParalyzableDeadTime={0},".format(self.sf_gui.paralyzable_deadtime), + r" DeadTime={0},".format(self.sf_gui.deadtime_value), + r" DeadTimeTOFStep={0},".format(self.sf_gui.deadtime_tof_step), + r")" + ] + script += "\n".join(mantid_call) + "\n" return script def refreshOutputFileContainPreview(self, output_file_name): diff --git a/test/ui/test_compute_scaling_factors.py b/test/ui/test_compute_scaling_factors.py index ec91eace..4f91cd39 100644 --- a/test/ui/test_compute_scaling_factors.py +++ b/test/ui/test_compute_scaling_factors.py @@ -17,8 +17,9 @@ # The run-set "184975-184989" overflows the RAM of the GitHub Actions runners test_cases = [("184977-184980", 4, "sf_export_script_184977_184980.py")] -if not os.environ.get("GITHUB_ACTIONS", False): - test_cases.append(("184975-184989", 15, "sf_export_script_184975_184989.py")) +# DEBUG: uncomment these lines +#if not os.environ.get("GITHUB_ACTIONS", False): +# test_cases.append(("184975-184989", 15, "sf_export_script_184975_184989.py")) @pytest.mark.parametrize("run_set, run_count, script_file", test_cases) From 2645cbd85cc8b6481a8b4acae97f82d4c12057fb Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Sat, 27 Apr 2024 17:26:01 -0400 Subject: [PATCH 4/5] remove DEBUG temporary changes Signed-off-by: Jose Borreguero --- test/ui/test_compute_scaling_factors.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/ui/test_compute_scaling_factors.py b/test/ui/test_compute_scaling_factors.py index 4f91cd39..ec91eace 100644 --- a/test/ui/test_compute_scaling_factors.py +++ b/test/ui/test_compute_scaling_factors.py @@ -17,9 +17,8 @@ # The run-set "184975-184989" overflows the RAM of the GitHub Actions runners test_cases = [("184977-184980", 4, "sf_export_script_184977_184980.py")] -# DEBUG: uncomment these lines -#if not os.environ.get("GITHUB_ACTIONS", False): -# test_cases.append(("184975-184989", 15, "sf_export_script_184975_184989.py")) +if not os.environ.get("GITHUB_ACTIONS", False): + test_cases.append(("184975-184989", 15, "sf_export_script_184975_184989.py")) @pytest.mark.parametrize("run_set, run_count, script_file", test_cases) From 47efb480d5194b0254bb201cfaec512551cf92fc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 27 Apr 2024 21:26:21 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../sf_calculator/reduction_sf_calculator.py | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/RefRed/sf_calculator/reduction_sf_calculator.py b/RefRed/sf_calculator/reduction_sf_calculator.py index f785ea3a..c5b7aacd 100644 --- a/RefRed/sf_calculator/reduction_sf_calculator.py +++ b/RefRed/sf_calculator/reduction_sf_calculator.py @@ -205,22 +205,23 @@ def generate_script( script += "from lr_reduction.scaling_factors import LRScalingFactors\n" script += "from lr_reduction.utils import mantid_algorithm_exec\n\n" - mantid_call = [r"mantid_algorithm_exec(", - r" LRScalingFactors.LRScalingFactors,", - r" DirectBeamRuns={0},".format(run_list), - r" IncidentMedium='{0}',".format(incident_medium), - r" TOFRange={0},".format(tof_range), - r" TOFSteps={0},".format(self.sf_gui.deadtime_tof_step), - r" SignalPeakPixelRange={0},".format(peak_ranges), - r" SignalBackgroundPixelRange={0},".format(bck_ranges), - r" LowResolutionPixelRange={0},".format(low_res_ranges), - r" ScalingFactorFile='{0}',".format(output_file_name), - r" UseDeadTimeCorrection={0},".format(self.sf_gui.apply_deadtime), - r" ParalyzableDeadTime={0},".format(self.sf_gui.paralyzable_deadtime), - r" DeadTime={0},".format(self.sf_gui.deadtime_value), - r" DeadTimeTOFStep={0},".format(self.sf_gui.deadtime_tof_step), - r")" - ] + mantid_call = [ + r"mantid_algorithm_exec(", + r" LRScalingFactors.LRScalingFactors,", + r" DirectBeamRuns={0},".format(run_list), + r" IncidentMedium='{0}',".format(incident_medium), + r" TOFRange={0},".format(tof_range), + r" TOFSteps={0},".format(self.sf_gui.deadtime_tof_step), + r" SignalPeakPixelRange={0},".format(peak_ranges), + r" SignalBackgroundPixelRange={0},".format(bck_ranges), + r" LowResolutionPixelRange={0},".format(low_res_ranges), + r" ScalingFactorFile='{0}',".format(output_file_name), + r" UseDeadTimeCorrection={0},".format(self.sf_gui.apply_deadtime), + r" ParalyzableDeadTime={0},".format(self.sf_gui.paralyzable_deadtime), + r" DeadTime={0},".format(self.sf_gui.deadtime_value), + r" DeadTimeTOFStep={0},".format(self.sf_gui.deadtime_tof_step), + r")", + ] script += "\n".join(mantid_call) + "\n" return script