From 86de1c25aa549977a3c4c243136fefa64f9957c4 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 2 May 2023 11:51:59 +0100 Subject: [PATCH] update paths to run from calibration root --- .github/workflows/pr_workflow.yml | 3 +- unpackaged/vesuvio_calibration/README.md | 4 +- .../calibrate_vesuvio_analysis.py | 3 +- .../calibrate_vesuvio_fit.py | 2 +- .../load_calibration_algorithms.py | 4 +- .../tests/system/test_system_analysis.py | 30 +-- .../tests/system/test_system_fit.py | 22 +-- .../tests/testhelpers/system_test_base.py | 2 +- .../testhelpers/system_test_misc_functions.py | 2 +- .../unit/test_calibrate_vesuvio_analysis.py | 2 +- .../tests/unit/test_calibrate_vesuvio_fit.py | 172 +++++++++--------- .../tests/unit/test_calibrate_vesuvio_misc.py | 10 +- 12 files changed, 129 insertions(+), 127 deletions(-) diff --git a/.github/workflows/pr_workflow.yml b/.github/workflows/pr_workflow.yml index 63865310..4ce286d3 100644 --- a/.github/workflows/pr_workflow.yml +++ b/.github/workflows/pr_workflow.yml @@ -39,7 +39,8 @@ jobs: - name: Run EVSVesuvio Calibration Unit Tests run: | export MANTIDPROPERTIES=$(pwd)/Mantid.user.properties - python -m unittest discover -s ./unpackaged/vesuvio_calibration/tests/unit + cd unpackaged/vesuvio_calibration + python -m unittest discover -s ./tests/unit #DISABLED AS THEY APPEAR TOO LARGE FOR GITHUB HOSTED RUNNERS #- name: Run Vesuvio Calibration System Tests diff --git a/unpackaged/vesuvio_calibration/README.md b/unpackaged/vesuvio_calibration/README.md index f8c7d5ff..ca7c711c 100644 --- a/unpackaged/vesuvio_calibration/README.md +++ b/unpackaged/vesuvio_calibration/README.md @@ -47,10 +47,10 @@ Upon running the script, the two calibration algorithms will be registered under 1. Actviate the conda environment using `conda activate vesuvio-env`. -2. From the root of the repository run `python -m unittest discover -s ./unpackaged/vesuvio_calibration/tests/unit` +2. From `/unpackaged/vesuvio_calibration` run `python -m unittest discover -s ./tests/unit` ## Running the system tests from the command line. 1. Actviate the conda environment using `conda activate vesuvio-env`. -2. From the root of the repository run `python -m unittest discover -s ./unpackaged/vesuvio_calibration/tests/system` +2. From `/unpackaged/vesuvio_calibration` run `python -m unittest discover -s ./tests/system` diff --git a/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_analysis.py b/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_analysis.py index ed1ee5e8..de66f8a4 100644 --- a/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_analysis.py +++ b/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_analysis.py @@ -3,7 +3,8 @@ from mantid.api import FileProperty, FileAction, PythonAlgorithm,AlgorithmManager from mantid.simpleapi import CreateEmptyTableWorkspace, DeleteWorkspace, ReplaceSpecialValues, GroupWorkspaces, mtd,\ ConvertTableToMatrixWorkspace, ConjoinWorkspaces, Transpose, PlotPeakByLogValue,RenameWorkspace -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals, EVSMiscFunctions +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals, EVSMiscFunctions + import os import sys diff --git a/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_fit.py b/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_fit.py index d6c37b24..1fbe846b 100644 --- a/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_fit.py +++ b/unpackaged/vesuvio_calibration/calibration_scripts/calibrate_vesuvio_fit.py @@ -6,7 +6,7 @@ ReplaceSpecialValues, FindPeaks, GroupWorkspaces, mtd, Plus, LoadVesuvio, LoadRaw, ConvertToDistribution, FindPeakBackground,\ ExtractSingleSpectrum, SumSpectra, AppendSpectra, CloneWorkspace, Fit, MaskDetectors, ExtractUnmaskedSpectra, CreateWorkspace from functools import partial -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals, EVSMiscFunctions +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals, EVSMiscFunctions import os import sys diff --git a/unpackaged/vesuvio_calibration/load_calibration_algorithms.py b/unpackaged/vesuvio_calibration/load_calibration_algorithms.py index 1c982c5e..96fcc672 100644 --- a/unpackaged/vesuvio_calibration/load_calibration_algorithms.py +++ b/unpackaged/vesuvio_calibration/load_calibration_algorithms.py @@ -13,8 +13,8 @@ """ from mantid.api import AlgorithmFactory -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_analysis import EVSCalibrationAnalysis +from calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit +from calibration_scripts.calibrate_vesuvio_analysis import EVSCalibrationAnalysis AlgorithmFactory.subscribe(EVSCalibrationFit) AlgorithmFactory.subscribe(EVSCalibrationAnalysis) diff --git a/unpackaged/vesuvio_calibration/tests/system/test_system_analysis.py b/unpackaged/vesuvio_calibration/tests/system/test_system_analysis.py index 5165d1e2..779568cd 100644 --- a/unpackaged/vesuvio_calibration/tests/system/test_system_analysis.py +++ b/unpackaged/vesuvio_calibration/tests/system/test_system_analysis.py @@ -4,12 +4,12 @@ from mantid.api import AlgorithmFactory from mantid.simpleapi import mtd from mock import patch -from unpackaged.vesuvio_calibration.tests.testhelpers.algorithms import create_algorithm -from unpackaged.vesuvio_calibration.tests.testhelpers.system_test_base import EVSCalibrationTest, TestConstants -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals -from unpackaged.vesuvio_calibration.tests.testhelpers.system_test_misc_functions import assert_allclose_excluding_bad_detectors -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_analysis import EVSCalibrationAnalysis -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit +from tests.testhelpers.algorithms import create_algorithm +from tests.testhelpers.system_test_base import EVSCalibrationTest, TestConstants +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals +from tests.testhelpers.system_test_misc_functions import assert_allclose_excluding_bad_detectors +from calibration_scripts.calibrate_vesuvio_analysis import EVSCalibrationAnalysis +from calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit from copy import copy from os import path @@ -40,7 +40,7 @@ def setUp(self): self._E1_fit = [False, True, True] self._L0_fit = [False] - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_copper(self, load_file_mock): self._setup_copper_test() self._output_workspace = "copper_analysis_test" @@ -55,7 +55,7 @@ def test_copper(self, load_file_mock): 165, 167, 168, 169, 170, 182, 191, 192]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_lead(self, load_file_mock): self._setup_lead_test() self._output_workspace = "lead_analysis_test" @@ -70,7 +70,7 @@ def test_lead(self, load_file_mock): 178, 180, 182, 183]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_niobium(self, load_file_mock): self._setup_niobium_test() self._output_workspace = "niobium_analysis_test" @@ -88,7 +88,7 @@ def test_niobium(self, load_file_mock): 182, 186, 187, 189, 191]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_copper_with_uranium(self, load_file_mock): self._setup_copper_test() self._output_workspace = "copper_analysis_test" @@ -103,7 +103,7 @@ def test_copper_with_uranium(self, load_file_mock): 165, 167, 168, 169, 170, 182, 191, 192]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_lead_with_uranium(self, load_file_mock): self._setup_lead_test() self._output_workspace = "lead_analysis_test" @@ -118,7 +118,7 @@ def test_lead_with_uranium(self, load_file_mock): 178, 180, 182, 183]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_copper_with_l0_calc(self, load_file_mock): self._setup_copper_test() self._L0_fit = [True, True, True, False, False, False] @@ -138,7 +138,7 @@ def test_copper_with_l0_calc(self, load_file_mock): 165, 167, 168, 169, 170, 182, 191, 192]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_copper_with_multiple_iterations(self, load_file_mock): self._setup_copper_test() self._iterations = 2 @@ -158,7 +158,7 @@ def test_copper_with_multiple_iterations(self, load_file_mock): 165, 167, 168, 169, 170, 182, 191, 192]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_copper_create_output(self, load_file_mock): self._setup_copper_test() self._output_workspace = "copper_analysis_test" @@ -175,7 +175,7 @@ def test_copper_create_output(self, load_file_mock): 165, 167, 168, 169, 170, 182, 191, 192]}) self._assert_parameters_match_expected(params_table, detector_specific_r_tols) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_copper_with_individual_and_global_fit(self, load_file_mock): self._setup_copper_test() self._output_workspace = "copper_analysis_test" diff --git a/unpackaged/vesuvio_calibration/tests/system/test_system_fit.py b/unpackaged/vesuvio_calibration/tests/system/test_system_fit.py index cc9343bc..0e4698ce 100644 --- a/unpackaged/vesuvio_calibration/tests/system/test_system_fit.py +++ b/unpackaged/vesuvio_calibration/tests/system/test_system_fit.py @@ -6,11 +6,11 @@ from mantid.api import WorkspaceGroup, AlgorithmFactory from mantid.simpleapi import mtd from mock import patch -from unpackaged.vesuvio_calibration.tests.testhelpers.algorithms import create_algorithm -from unpackaged.vesuvio_calibration.tests.testhelpers.system_test_base import EVSCalibrationTest, TestConstants -from unpackaged.vesuvio_calibration.tests.testhelpers.system_test_misc_functions import assert_allclose_excluding_bad_detectors -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSMiscFunctions, EVSGlobals -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit +from tests.testhelpers.algorithms import create_algorithm +from tests.testhelpers.system_test_base import EVSCalibrationTest, TestConstants +from tests.testhelpers.system_test_misc_functions import assert_allclose_excluding_bad_detectors +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSMiscFunctions, EVSGlobals +from calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit from os import path @@ -40,7 +40,7 @@ def setUp(self): self._E1_fit = [False] self._L0_fit = [False] - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_fit_bragg_peaks_copper(self, load_file_mock): self._setup_copper_test() self._spec_range = [EVSGlobals.DETECTOR_RANGE] @@ -52,7 +52,7 @@ def test_fit_bragg_peaks_copper(self, load_file_mock): params_table = self._run_evs_calibration_fit("Bragg") self._assert_fitted_positions_match_expected(expected_values, params_table, {15: TestConstants.IGNORE_DETECTOR}) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_fit_bragg_peaks_lead(self, load_file_mock): self._setup_lead_test() self._spec_range = [EVSGlobals.DETECTOR_RANGE] @@ -65,7 +65,7 @@ def test_fit_bragg_peaks_lead(self, load_file_mock): self._assert_fitted_positions_match_expected(expected_values, params_table, {145: 0.27, 158: 0.15, 190: TestConstants.IGNORE_DETECTOR}) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_fit_peaks_copper_E1(self, load_file_mock): self._setup_copper_test() self._E1_fit_active = True @@ -79,7 +79,7 @@ def test_fit_peaks_copper_E1(self, load_file_mock): params_table = self._run_evs_calibration_fit("Recoil") self._assert_fitted_positions_match_expected(expected_values, params_table, {38: 0.12}) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_fit_peaks_lead_E1(self, load_file_mock): self._setup_lead_test() self._E1_fit_active = True @@ -93,7 +93,7 @@ def test_fit_peaks_lead_E1(self, load_file_mock): params_table = self._run_evs_calibration_fit("Recoil") self._assert_fitted_positions_match_expected(expected_values, params_table, {38: 0.12}) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_fit_frontscattering_uranium(self, load_file_mock): self._setup_uranium_test() self._run_range = EVSGlobals.U_FRONTSCATTERING_SAMPLE @@ -107,7 +107,7 @@ def test_fit_frontscattering_uranium(self, load_file_mock): params_table = self._run_evs_calibration_fit("Recoil") self._assert_fitted_positions_match_expected(expected_values, params_table) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_fit_backscattering_uranium(self, load_file_mock): self._setup_uranium_test() self._run_range = EVSGlobals.U_BACKSCATTERING_SAMPLE diff --git a/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_base.py b/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_base.py index 3bab0fe9..1b9532d5 100644 --- a/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_base.py +++ b/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_base.py @@ -1,7 +1,7 @@ import unittest import numpy as np from mantid.simpleapi import LoadVesuvio, LoadRaw, mtd, ConvertToDistribution -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals from os import path diff --git a/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_misc_functions.py b/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_misc_functions.py index d507f4c2..f0524e07 100644 --- a/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_misc_functions.py +++ b/unpackaged/vesuvio_calibration/tests/testhelpers/system_test_misc_functions.py @@ -1,6 +1,6 @@ import numpy as np from sys import maxsize -from unpackaged.vesuvio_calibration.tests.testhelpers.system_test_base import TestConstants +from tests.testhelpers.system_test_base import TestConstants def assert_allclose_excluding_bad_detectors(expected_position, position, rtol, default_rtol=TestConstants.DEFAULT_RELATIVE_TOLERANCE): diff --git a/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_analysis.py b/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_analysis.py index 14aadddd..3453a535 100644 --- a/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_analysis.py +++ b/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_analysis.py @@ -1,4 +1,4 @@ -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_analysis import EVSCalibrationAnalysis +from calibration_scripts.calibrate_vesuvio_analysis import EVSCalibrationAnalysis import unittest diff --git a/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_fit.py b/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_fit.py index 97c299a5..3c8bce65 100644 --- a/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_fit.py +++ b/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_fit.py @@ -1,5 +1,5 @@ -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals +from calibration_scripts.calibrate_vesuvio_fit import EVSCalibrationFit +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSGlobals from mock import MagicMock, patch, call from functools import partial from mantid.kernel import IntArrayProperty, StringArrayProperty, FloatArrayProperty @@ -30,9 +30,9 @@ def side_effect_set_cell(self, arg1, arg2, value): def side_effect_cell(row_index, col_index, peaks): return peaks[row_index] - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_perfect_match(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -64,9 +64,9 @@ def test_filter_peaks_perfect_match(self, mock_mtd, mock_clone_workspace, mock_d mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_no_match(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -96,9 +96,9 @@ def test_filter_peaks_no_match(self, mock_mtd, mock_clone_workspace, mock_del_wo OutputWorkspace=find_peaks_output_name + '_unfiltered') mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_one_match(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -129,9 +129,9 @@ def test_filter_peaks_one_match(self, mock_mtd, mock_clone_workspace, mock_del_w OutputWorkspace=find_peaks_output_name + '_unfiltered') mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_two_match(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -163,9 +163,9 @@ def test_filter_peaks_two_match(self, mock_mtd, mock_clone_workspace, mock_del_w mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_does_not_include_higher_found_peak(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -196,9 +196,9 @@ def test_filter_peaks_does_not_include_higher_found_peak(self, mock_mtd, mock_cl OutputWorkspace=find_peaks_output_name + '_unfiltered') mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_does_not_include_lower_found_peak(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -230,9 +230,9 @@ def test_filter_peaks_does_not_include_lower_found_peak(self, mock_mtd, mock_clo mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_handles_multiple_peaks(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -263,9 +263,9 @@ def test_filter_peaks_handles_multiple_peaks(self, mock_mtd, mock_clone_workspac mock_del_workspace.assert_called_with(find_peaks_output_name + '_unfiltered') #Found peaks sometimes returns 'zero' peaks, usually at the end of the table workspace. - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.CloneWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_filter_peaks_handles_zero_position_in_found_peaks(self, mock_mtd, mock_clone_workspace, mock_del_workspace): alg = EVSCalibrationFit() @@ -316,7 +316,7 @@ def side_effect(arg1, arg2): np.testing.assert_almost_equal([9629.84, 13619.43, 15727.03], estimated_positions.flatten().tolist(), 0.01) print(estimated_positions) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_check_nans_false(self, mock_mtd): alg = EVSCalibrationFit() table_ws = 'table_ws' @@ -331,7 +331,7 @@ def test_check_nans_false(self, mock_mtd): self.assertFalse(alg._check_nans(table_ws)) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_check_nans_true(self, mock_mtd): alg = EVSCalibrationFit() table_ws = 'table_ws' @@ -360,12 +360,12 @@ def test_PyInit_property_defaults(self): self.assertEqual(expected_value, properties[prop], f'Property {prop}. Expected: {expected_value},' f'Actual: {properties[prop]}') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_spectra_list') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_run_numbers_and_output_workspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_function_type') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_parameter_workspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_peaks_and_set_crop_and_fit_ranges') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_class_variables_from_properties') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_spectra_list') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_run_numbers_and_output_workspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_function_type') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_parameter_workspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_peaks_and_set_crop_and_fit_ranges') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._setup_class_variables_from_properties') def test_setup_calls_all_functions(self, mock_setup_vars, mock_setup_peaks, mock_setup_param_ws, mock_setup_fn_type, mock_setup_run_nos, mock_setup_spec): alg = EVSCalibrationFit() @@ -480,7 +480,7 @@ def test_setup_parameter_workspace(self): self.assertEqual('test_ws', alg._param_workspace) self.assertEqual('test_ws', alg._param_table) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSMiscFunctions.load_instrument_parameters') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSMiscFunctions.load_instrument_parameters') def test_setup_parameter_workspace_no_ws(self, mock_load_instrument_parameters): alg = EVSCalibrationFit() alg.declareProperty('InstrumentParameterWorkspace', '') @@ -517,8 +517,8 @@ def test_setup_peaks_and_set_crop_and_fit_ranges_resonance(self): self.assertEqual(EVSGlobals.RESONANCE_PEAK_CROP_RANGE, alg._ws_crop_range) self.assertEqual(EVSGlobals.RESONANCE_FIT_WINDOW_RANGE, alg._fit_window_range) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.ReplaceSpecialValues') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_to_ads_and_crop') + @patch('calibration_scripts.calibrate_vesuvio_fit.ReplaceSpecialValues') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_to_ads_and_crop') def test_preprocess_no_bg(self, mock_load_to_ads_and_crop, mock_replace_special_values): test_run_numbers = [1, 2, 3, 4] test_crop_range = [3, 10] @@ -535,9 +535,9 @@ def test_preprocess_no_bg(self, mock_load_to_ads_and_crop, mock_replace_special_ mock_replace_special_values.assert_called_once_with(test_sample_ws_name, NaNValue=0, NaNError=0, InfinityValue=0, InfinityError=0, OutputWorkspace=test_sample_ws_name) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._normalise_sample_by_background') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.ReplaceSpecialValues') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_to_ads_and_crop') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._normalise_sample_by_background') + @patch('calibration_scripts.calibrate_vesuvio_fit.ReplaceSpecialValues') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_to_ads_and_crop') def test_preprocess_with_bg(self, mock_load_to_ads_and_crop, mock_replace_special_values, mock_normalise_sample): test_run_numbers = [1, 2, 3, 4] test_bg_run_numbers = [5, 6] @@ -559,8 +559,8 @@ def test_preprocess_with_bg(self, mock_load_to_ads_and_crop, mock_replace_specia mock_replace_special_values.assert_called_once_with(test_sample_ws_name, NaNValue=0, NaNError=0, InfinityValue=0, InfinityError=0, OutputWorkspace=test_sample_ws_name) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CropWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_files') + @patch('calibration_scripts.calibrate_vesuvio_fit.CropWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_files') def test_load_to_ads_and_crop(self, mock_load_files, mock_crop_workspace): alg = EVSCalibrationFit() run_numbers = [1, 2, 3, 4] @@ -572,9 +572,9 @@ def test_load_to_ads_and_crop(self, mock_load_files, mock_crop_workspace): mock_load_files.assert_called_once_with(run_numbers, output) mock_crop_workspace.assert_called_once_with(output, XMin=xmin, XMax=xmax, OutputWorkspace=output) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.Divide') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.RebinToWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.Divide') + @patch('calibration_scripts.calibrate_vesuvio_fit.RebinToWorkspace') def test_normalise_sample_by_background(self, mock_rebin, mock_divide, mock_delete): alg = EVSCalibrationFit() sample_ws = 'test_ws' @@ -588,9 +588,9 @@ def test_normalise_sample_by_background(self, mock_rebin, mock_divide, mock_dele mock_divide.assert_called_once_with(sample_ws, bg_ws, OutputWorkspace=sample_ws) mock_delete.assert_called_once_with(bg_ws) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.Plus') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.Plus') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._load_file') def test_load_files(self, mock_load_file, mock_plus, mock_delete): alg = EVSCalibrationFit() ws_numbers = ['1-4'] # Note this is parsed as '1-3', is this intentional? @@ -602,8 +602,8 @@ def test_load_files(self, mock_load_file, mock_plus, mock_delete): call(output_name, '__EVS_calib_temp_ws', OutputWorkspace=output_name)]) mock_delete.assert_has_calls([call('__EVS_calib_temp_ws'), call('__EVS_calib_temp_ws')]) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.LoadRaw') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.LoadVesuvio') + @patch('calibration_scripts.calibrate_vesuvio_fit.LoadRaw') + @patch('calibration_scripts.calibrate_vesuvio_fit.LoadVesuvio') def test_load_file_vesuvio(self, mock_load_vesuvio, mock_load_raw): alg = EVSCalibrationFit() ws_name = 'test_file' @@ -619,9 +619,9 @@ def test_load_file_vesuvio(self, mock_load_vesuvio, mock_load_raw): EnableLogging=False) mock_load_raw.assert_not_called() - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.ConvertToDistribution') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.LoadRaw') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.LoadVesuvio') + @patch('calibration_scripts.calibrate_vesuvio_fit.ConvertToDistribution') + @patch('calibration_scripts.calibrate_vesuvio_fit.LoadRaw') + @patch('calibration_scripts.calibrate_vesuvio_fit.LoadVesuvio') def test_load_file_raw(self, mock_load_vesuvio, mock_load_raw, mock_convert_to_dist): alg = EVSCalibrationFit() ws_name = 'test_file' @@ -638,7 +638,7 @@ def test_load_file_raw(self, mock_load_vesuvio, mock_load_raw, mock_convert_to_d EnableLogging=False) mock_convert_to_dist.assert_called_once_with(output_name, EnableLogging=False) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') + @patch('calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') def test_fit_peaks_individual(self, group_workspaces_mock): alg = EVSCalibrationFit() alg._estimate_peak_positions = MagicMock(return_value=np.asarray([[5, 10, 15], [2.5, 7.5, 10.5]])) @@ -660,8 +660,8 @@ def test_fit_peaks_individual(self, group_workspaces_mock): group_workspaces_mock.assert_called_once_with(['output_ws_name_Peak_0_Parameters', 'output_ws_name_Peak_1_Parameters'], OutputWorkspace='output_ws_name_Peak_Parameters') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._shared_parameter_fit') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._shared_parameter_fit') + @patch('calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') def test_fit_peaks_shared(self, group_workspaces_mock, shared_parameter_fit_mock): alg = EVSCalibrationFit() alg._estimate_peak_positions = MagicMock(return_value=np.asarray([[5, 10, 15], [2.5, 7.5, 10.5]])) @@ -684,8 +684,8 @@ def test_fit_peaks_shared(self, group_workspaces_mock, shared_parameter_fit_mock OutputWorkspace='output_ws_name_Peak_Parameters') shared_parameter_fit_mock.assert_called_once_with('output_ws_name_Peak_1_Parameters', ['a', 'b', 'c']) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._shared_parameter_fit') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._shared_parameter_fit') + @patch('calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') def test_fit_peaks_both(self, group_workspaces_mock, shared_parameter_fit_mock): alg = EVSCalibrationFit() alg._estimate_peak_positions = MagicMock(return_value=np.asarray([[5, 10, 15], [2.5, 7.5, 10.5]])) @@ -723,7 +723,7 @@ def _setup_alg_mocks_fit_peak(): return alg - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.Fit') + @patch('calibration_scripts.calibrate_vesuvio_fit.Fit') def test_fit_peak(self, mock_fit): alg = self._setup_alg_mocks_fit_peak() @@ -747,9 +747,9 @@ def test_fit_peak(self, mock_fit): self.assertEqual(fit_workspace_name, 'fws') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.FindPeaks') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.FindPeaks') def test_find_peaks_and_output_params(self, find_peaks_mock, delete_workspace_mock, mtd_mock): alg = EVSCalibrationFit() alg._sample = 'sample' @@ -767,11 +767,11 @@ def test_find_peaks_and_output_params(self, find_peaks_mock, delete_workspace_mo peak_table_name_ws.rowCount.assert_called_once() delete_workspace_mock.assert_called_once_with('__sample_peaks_table_0_3') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.sys') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.logger.error') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.FindPeaks') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._get_find_peak_parameters') + @patch('calibration_scripts.calibrate_vesuvio_fit.sys') + @patch('calibration_scripts.calibrate_vesuvio_fit.logger.error') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.FindPeaks') + @patch('calibration_scripts.calibrate_vesuvio_fit.EVSCalibrationFit._get_find_peak_parameters') def test_find_peaks_and_output_params_no_peaks_found(self, find_peak_params_mock, find_peaks_mock, mtd_mock, logger_mock, sys_mock): alg = EVSCalibrationFit() @@ -802,7 +802,7 @@ def test_find_fit_x_window(self): self.assertEqual(3, xmin) self.assertEqual(7, xmax) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.logger.warning') + @patch('calibration_scripts.calibrate_vesuvio_fit.logger.warning') def test_find_fit_x_window_position_less_than_1(self, logger_mock): alg = EVSCalibrationFit() alg._func_param_names = {'Position': 'Position_key'} @@ -823,7 +823,7 @@ def _params_column_side_effect(self, col_index): else: raise ValueError("incorrect column index supplied") - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_output_fit_params_to_table_ws(self, mtd_mock): alg = EVSCalibrationFit() spec_num = 45 @@ -838,22 +838,22 @@ def test_output_fit_params_to_table_ws(self, mtd_mock): mtd_mock.__getitem__.assert_called_once_with(output_table_name) output_table_ws_mock.addRow.assert_called_once_with([spec_num, 1, 0.1, 2, 0.2, 3, 0.3]) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') def test_del_fit_workspace(self, del_ws_mock): alg = EVSCalibrationFit() alg._create_output = True alg._del_fit_workspaces('ncm', 'params', 'fws') del_ws_mock.assert_has_calls([call('ncm'), call('params')]) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') def test_del_fit_workspace_create_output_true(self, del_ws_mock): alg = EVSCalibrationFit() alg._create_output = False alg._del_fit_workspaces('ncm', 'params', 'fws') del_ws_mock.assert_has_calls([call('ncm'), call('params'), call('fws')]) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.CreateEmptyTableWorkspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.AnalysisDataService') + @patch('calibration_scripts.calibrate_vesuvio_fit.CreateEmptyTableWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.AnalysisDataService') def test_create_output_parameters_table_ws(self, mock_ADS, mock_create_empty_table_ws): output_table_name = 'test_output_table' num_estimated_peaks = 3 @@ -920,7 +920,7 @@ def test_select_best_fit_params_unconstrained_has_invalid_peaks(self): self.assertEqual(selected_params, fit_results['params']) self.assertFalse(unconstrained_fit_selected) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_output_params_to_table(self, mock_mtd_module): alg = EVSCalibrationFit() spec_num = 1 @@ -949,7 +949,7 @@ def test_output_params_to_table(self, mock_mtd_module): expected_row = [1, 0.1, 2, 0.2, 3, 0.3, 4, 0.4, 5, 0.5] mock_output_table.addRow.assert_called_once_with([spec_num] + expected_row) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') def test_get_output_and_clean_workspaces_unconstrained_not_performed(self, mock_delete_ws): alg = EVSCalibrationFit() find_peaks_output_name = 'test_find_output_name' @@ -960,7 +960,7 @@ def test_get_output_and_clean_workspaces_unconstrained_not_performed(self, mock_ call(find_peaks_output_name)]) self.assertEqual(output_ws, fit_peaks_output_name + '_Workspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') def test_get_output_and_clean_workspaces_unconstrained_performed(self, mock_delete_ws): alg = EVSCalibrationFit() find_peaks_output_name = 'test_find_output_name' @@ -975,7 +975,7 @@ def test_get_output_and_clean_workspaces_unconstrained_performed(self, mock_dele call(fit_peaks_output_name + '_unconstrained_Workspace')]) self.assertEqual(output_ws, fit_peaks_output_name + '_Workspace') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') + @patch('calibration_scripts.calibrate_vesuvio_fit.DeleteWorkspace') def test_get_output_and_clean_workspaces_unconstrained_performed_and_selected(self, mock_delete_ws): alg = EVSCalibrationFit() find_peaks_output_name = 'test_find_output_name' @@ -1026,8 +1026,8 @@ def _setup_mtd_mock(mtd_mock_obj, find_peaks_name, peaks_found): mtd_mock_obj.__getitem__.side_effect = lambda name: mock_find_peaks_output if\ name == find_peaks_name else None - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.FindPeaks') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.FindPeaks') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_run_find_peaks_peaks_found(self, mock_mtd_module, mock_find_peaks): alg, fn_args = self._setup_run_find_peaks_test(unconstrained=False) @@ -1037,8 +1037,8 @@ def test_run_find_peaks_peaks_found(self, mock_mtd_module, mock_find_peaks): mock_find_peaks.assert_called_once() self.assertTrue(result) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.FindPeaks') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.FindPeaks') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_run_find_peaks_no_peaks_found_raises_value_error(self, mock_mtd_module, mock_find_peaks): alg, fn_args = self._setup_run_find_peaks_test(unconstrained=False) @@ -1048,8 +1048,8 @@ def test_run_find_peaks_no_peaks_found_raises_value_error(self, mock_mtd_module, alg._run_find_peaks(**fn_args) mock_find_peaks.assert_called_once() - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.FindPeaks') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.mtd') + @patch('calibration_scripts.calibrate_vesuvio_fit.FindPeaks') + @patch('calibration_scripts.calibrate_vesuvio_fit.mtd') def test_run_find_peaks_unconstrained_no_peaks_found_no_error(self, mock_mtd_module, mock_find_peaks): alg, fn_args = self._setup_run_find_peaks_test(unconstrained=True) @@ -1059,7 +1059,7 @@ def test_run_find_peaks_unconstrained_no_peaks_found_no_error(self, mock_mtd_mod mock_find_peaks.assert_called_once() self.assertFalse(result) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.FindPeaks') + @patch('calibration_scripts.calibrate_vesuvio_fit.FindPeaks') def test_run_find_peaks_unconstrained_peaks_found_raises_error(self, mock_find_peaks): alg, fn_args = self._setup_run_find_peaks_test(unconstrained=True) @@ -1221,7 +1221,7 @@ def _test_calls_individually(self, call_list, calls): except ValueError: np.testing.assert_array_equal(arg, expected_arg) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') + @patch('calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') def test_fit_bragg_peaks_success(self, group_workspaces_mock): fit_result_ret_val = {'status': 'success'} fit_results = lambda *args: fit_result_ret_val @@ -1243,7 +1243,7 @@ def test_fit_bragg_peaks_success(self, group_workspaces_mock): call(False, False, False, 'sample_peaks_table_2', 'output_Spec_2')]) group_workspaces_mock.assert_called_once_with(','.join(output_workspaces), OutputWorkspace='output_Peak_Fits') - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') + @patch('calibration_scripts.calibrate_vesuvio_fit.GroupWorkspaces') def test_fit_bragg_peaks_not_success(self, group_workspaces_mock): x_range = (1, 2) fit_res = {'status': 'failure', 'xmin': x_range[0], 'xmax': x_range[1]} diff --git a/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_misc.py b/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_misc.py index c3010c17..d995dff3 100644 --- a/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_misc.py +++ b/unpackaged/vesuvio_calibration/tests/unit/test_calibrate_vesuvio_misc.py @@ -1,4 +1,4 @@ -from unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions import EVSMiscFunctions +from calibration_scripts.calibrate_vesuvio_helper_functions import EVSMiscFunctions from mock import MagicMock, patch import unittest @@ -34,7 +34,7 @@ def test_generate_header_function_invalid(self): with self.assertRaises(ValueError): EVSMiscFunctions.generate_fit_function_header("Invalid") - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions.mtd') + @patch('calibration_scripts.calibrate_vesuvio_helper_functions.mtd') def test_identify_invalid_spectra_no_invalid(self, mock_mtd): ws_mock = MagicMock() mock_column_output_dict = {'f1.GaussianFWHM': [1, 2, 3], 'f1.GaussianFWHM_Err': [0.1, 0.2, 0.3], @@ -46,7 +46,7 @@ def test_identify_invalid_spectra_no_invalid(self, mock_mtd): np.testing.assert_equal(np.argwhere([]), EVSMiscFunctions.identify_invalid_spectra('peak_table', [5, 10, 20], [0.1, 0.15, 0.2], [0, 2])) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions.mtd') + @patch('calibration_scripts.calibrate_vesuvio_helper_functions.mtd') def test_identify_invalid_spectra_nan_in_errors(self, mock_mtd): ws_mock = MagicMock() mock_column_output_dict = {'f1.GaussianFWHM': [1, 2, 3], 'f1.GaussianFWHM_Err': [np.nan, 0.2, 0.3], @@ -58,7 +58,7 @@ def test_identify_invalid_spectra_nan_in_errors(self, mock_mtd): np.testing.assert_equal(np.argwhere(np.array([True, False, True])), EVSMiscFunctions.identify_invalid_spectra('peak_table', [5, 10, 20], [0.1, 0.15, 0.2], [0, 2])) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions.mtd') + @patch('calibration_scripts.calibrate_vesuvio_helper_functions.mtd') def test_identify_invalid_spectra_inf_in_errors(self, mock_mtd): ws_mock = MagicMock() mock_column_output_dict = {'f1.GaussianFWHM': [1, 2, 3], 'f1.GaussianFWHM_Err': [0.1, 0.2, 0.3], @@ -70,7 +70,7 @@ def test_identify_invalid_spectra_inf_in_errors(self, mock_mtd): np.testing.assert_equal(np.argwhere(np.array([True, True, False])), EVSMiscFunctions.identify_invalid_spectra('peak_table', [5, 10, 20], [0.1, 0.15, 0.2], [0, 2])) - @patch('unpackaged.vesuvio_calibration.calibration_scripts.calibrate_vesuvio_helper_functions.mtd') + @patch('calibration_scripts.calibrate_vesuvio_helper_functions.mtd') def test_identify_invalid_spectra_error_greater_than_peak(self, mock_mtd): ws_mock = MagicMock() mock_column_output_dict = {'f1.GaussianFWHM': [1, 2, 3], 'f1.GaussianFWHM_Err': [0.1, 0.2, 0.3],