|
| 1 | +import unittest |
| 2 | +import numpy as np |
| 3 | +import numpy.testing as nptest |
| 4 | +from mock import MagicMock |
| 5 | +from mvesuvio.analysis_reduction import AnalysisRoutine |
| 6 | +from mantid.simpleapi import CreateWorkspace, DeleteWorkspace |
| 7 | + |
| 8 | + |
| 9 | +class TestAnalysisFunctions(unittest.TestCase): |
| 10 | + def setUp(self): |
| 11 | + pass |
| 12 | + |
| 13 | + def test_calculate_h_ratio_masses_ordered(self): |
| 14 | + alg = AnalysisRoutine() |
| 15 | + alg._mean_intensity_ratios = np.array([0.91175, 0.06286, 0.00732, 0.01806]) |
| 16 | + alg._masses = np.array([1.0079, 12.0, 16.0, 27.0]) |
| 17 | + h_ratio = alg.calculate_h_ratio() |
| 18 | + self.assertAlmostEqual(14.504454343, h_ratio) |
| 19 | + |
| 20 | + def test_calculate_h_ratio_masses_unordered(self): |
| 21 | + alg = AnalysisRoutine() |
| 22 | + alg._mean_intensity_ratios = np.array([0.00732, 0.06286, 0.01806, 0.91175]) |
| 23 | + alg._masses = np.array([16.0, 12.0, 27.0, 1.0079]) |
| 24 | + h_ratio = alg.calculate_h_ratio() |
| 25 | + self.assertAlmostEqual(14.504454343, h_ratio) |
| 26 | + |
| 27 | + def test_calculate_h_ratio_hydrogen_missing(self): |
| 28 | + alg = AnalysisRoutine() |
| 29 | + alg._mean_intensity_ratios = np.array([0.00732, 0.06286, 0.01806]) |
| 30 | + alg._masses = np.array([16.0, 12.0, 27.0]) |
| 31 | + h_ratio = alg.calculate_h_ratio() |
| 32 | + self.assertAlmostEqual(None, h_ratio) |
| 33 | + |
| 34 | + |
| 35 | +if __name__ == "__main__": |
| 36 | + unittest.main() |
0 commit comments