Package test_suite :: Package unit_tests :: Package _specific_analyses :: Module test_n_state_model
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._specific_analyses.test_n_state_model

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2008-2013 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Python module imports. 
23  from math import pi 
24  from unittest import TestCase 
25   
26  # relax module imports. 
27  from specific_analyses.n_state_model import parameters 
28  from test_suite.unit_tests.n_state_model_testing_base import N_state_model_base_class 
29   
30   
31 -class Test_n_state_model(N_state_model_base_class, TestCase):
32 """Unit tests for the functions of the 'specific_analyses.n_state_model' module.""" 33 34 # Place the specific_analyses.n_state_model module into the class namespace. 35 n_state_model_fns = parameters 36 37
39 """Test the operation of the specific_analyses.n_state_model.parameters.assemble_param_vector() method.""" 40 41 # Set up the N, probabilities and Euler angles. 42 cdp.N = 3 43 cdp.probs = [0.1, 0.3, 0.6] 44 cdp.alpha = [0.0, pi/2, pi] 45 cdp.beta = [pi/2, pi, 3*pi/2] 46 cdp.gamma = [1.0, 3*pi/2, 2*pi] 47 cdp.model = '2-domain' 48 49 # Set up a dummy alignment tensor variable to allow the test to pass. 50 cdp.align_tensors = None 51 52 # Get the parameter vector. 53 param_vector = self.n_state_model_fns.assemble_param_vector() 54 55 # The correct result. 56 vector_true = [0.1, 0.3, 0.0, pi/2, 1.0, pi/2, pi, 3*pi/2, pi, 3*pi/2, 2*pi] 57 58 # Check the vector. 59 self.assertEqual(len(param_vector), len(vector_true)) 60 for i in range(len(param_vector)): 61 self.assertEqual(param_vector[i], vector_true[i])
62 63
65 """Test the operation of the specific_analyses.n_state_model.parameters.disassemble_param_vector() method.""" 66 67 # Set up the initial N, probabilities and Euler angles. 68 cdp.N = 3 69 cdp.probs = [None]*3 70 cdp.alpha = [None]*3 71 cdp.beta = [None]*3 72 cdp.gamma = [None]*3 73 cdp.model = '2-domain' 74 75 # The parameter vector. 76 param_vector = [0.1, 0.3, 0.0, pi/2, 1.0, pi/2, pi, 3*pi/2, pi, 3*pi/2, 2*pi] 77 78 # Disassemble the parameter vector. 79 self.n_state_model_fns.disassemble_param_vector(param_vector, data_types=['tensor']) 80 81 # Check the probabilities. 82 self.assertEqual(cdp.probs, [0.1, 0.3, 0.6]) 83 self.assertEqual(cdp.alpha, [0.0, pi/2, pi]) 84 self.assertEqual(cdp.beta, [pi/2, pi, 3*pi/2]) 85 self.assertEqual(cdp.gamma, [1.0, 3*pi/2, 2*pi])
86