Skip to content

Commit

Permalink
update paths to run from calibration root
Browse files Browse the repository at this point in the history
  • Loading branch information
MialLewis committed May 2, 2023
1 parent 1fa741e commit 1293de7
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 131 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions unpackaged/vesuvio_calibration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<root of the repository>/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 `<root of the repository>/unpackaged/vesuvio_calibration` run `python -m unittest discover -s ./tests/system`
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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,\
InvalidDetectors

import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
InvalidDetectors

import os
Expand Down
4 changes: 2 additions & 2 deletions unpackaged/vesuvio_calibration/load_calibration_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
32 changes: 16 additions & 16 deletions unpackaged/vesuvio_calibration/tests/system/test_system_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, deepcopy
from os import path

Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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_create_invalid_detectors_specified(self, load_file_mock):
self._setup_copper_test()
self._output_workspace = "copper_analysis_test"
Expand All @@ -196,7 +196,7 @@ def test_copper_create_invalid_detectors_specified(self, load_file_mock):
detector_specific_r_tols["L1"].update({k: TestConstants.INVALID_DETECTOR for k in [0, 2, 4]})
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"
Expand Down
22 changes: 11 additions & 11 deletions unpackaged/vesuvio_calibration/tests/system/test_system_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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


Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading

0 comments on commit 1293de7

Please sign in to comment.