-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for calculate h ratio
Added unit tests and removed old comments
- Loading branch information
1 parent
b0991a0
commit 1ffa208
Showing
2 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
import numpy as np | ||
import numpy.testing as nptest | ||
from mock import MagicMock | ||
from mvesuvio.analysis_reduction import AnalysisRoutine | ||
from mantid.simpleapi import CreateWorkspace, DeleteWorkspace | ||
|
||
|
||
class TestAnalysisFunctions(unittest.TestCase): | ||
def setUp(self): | ||
pass | ||
|
||
def test_calculate_h_ratio_masses_ordered(self): | ||
alg = AnalysisRoutine() | ||
alg._mean_intensity_ratios = np.array([0.91175, 0.06286, 0.00732, 0.01806]) | ||
alg._masses = np.array([1.0079, 12.0, 16.0, 27.0]) | ||
h_ratio = alg.calculate_h_ratio() | ||
self.assertAlmostEqual(14.504454343, h_ratio) | ||
|
||
def test_calculate_h_ratio_masses_unordered(self): | ||
alg = AnalysisRoutine() | ||
alg._mean_intensity_ratios = np.array([0.00732, 0.06286, 0.01806, 0.91175]) | ||
alg._masses = np.array([16.0, 12.0, 27.0, 1.0079]) | ||
h_ratio = alg.calculate_h_ratio() | ||
self.assertAlmostEqual(14.504454343, h_ratio) | ||
|
||
def test_calculate_h_ratio_hydrogen_missing(self): | ||
alg = AnalysisRoutine() | ||
alg._mean_intensity_ratios = np.array([0.00732, 0.06286, 0.01806]) | ||
alg._masses = np.array([16.0, 12.0, 27.0]) | ||
h_ratio = alg.calculate_h_ratio() | ||
self.assertAlmostEqual(None, h_ratio) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |