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

Source Code for Module test_suite.unit_tests._specific_fns.test_n_state_model

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2008 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax.                                     # 
 6  #                                                                             # 
 7  # relax 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 2 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # relax 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 relax; if not, write to the Free Software                        # 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Python module imports. 
24  from math import pi 
25  from unittest import TestCase 
26   
27  # relax module imports. 
28  from specific_fns import n_state_model 
29  from test_suite.unit_tests.n_state_model_testing_base import N_state_model_base_class 
30   
31   
32 -class Test_n_state_model(N_state_model_base_class, TestCase):
33 """Unit tests for the functions of the 'specific_fns.n_state_model' module.""" 34 35 # Place the specific_fns.n_state_model module into the class namespace. 36 n_state_model_fns = n_state_model.N_state_model() 37 38
40 """Test the operation of the specific_fns.n_state_model._assemble_param_vector() method.""" 41 42 # Set up the N, probabilities and Euler angles. 43 cdp.N = 3 44 cdp.probs = [0.1, 0.3, 0.6] 45 cdp.alpha = [0.0, pi/2, pi] 46 cdp.beta = [pi/2, pi, 3*pi/2] 47 cdp.gamma = [1.0, 3*pi/2, 2*pi] 48 cdp.model = '2-domain' 49 50 # Set up a dummy alignment tensor variable to allow the test to pass. 51 cdp.align_tensors = None 52 53 # Get the parameter vector. 54 param_vector = self.n_state_model_fns._assemble_param_vector() 55 56 # The correct result. 57 vector_true = [0.1, 0.3, 0.0, pi/2, 1.0, pi/2, pi, 3*pi/2, pi, 3*pi/2, 2*pi] 58 59 # Check the vector. 60 self.assertEqual(len(param_vector), len(vector_true)) 61 for i in xrange(len(param_vector)): 62 self.assertEqual(param_vector[i], vector_true[i])
63 64
66 """Test the operation of the specific_fns.n_state_model._disassemble_param_vector() method.""" 67 68 # Set up the initial N, probabilities and Euler angles. 69 cdp.N = 3 70 cdp.probs = [None]*3 71 cdp.alpha = [None]*3 72 cdp.beta = [None]*3 73 cdp.gamma = [None]*3 74 cdp.model = '2-domain' 75 76 # The parameter vector. 77 param_vector = [0.1, 0.3, 0.0, pi/2, 1.0, pi/2, pi, 3*pi/2, pi, 3*pi/2, 2*pi] 78 79 # Disassemble the parameter vector. 80 self.n_state_model_fns._disassemble_param_vector(param_vector, data_types=['tensor']) 81 82 # Check the probabilities. 83 self.assertEqual(cdp.probs, [0.1, 0.3, 0.6]) 84 self.assertEqual(cdp.alpha, [0.0, pi/2, pi]) 85 self.assertEqual(cdp.beta, [pi/2, pi, 3*pi/2]) 86 self.assertEqual(cdp.gamma, [1.0, 3*pi/2, 2*pi])
87