Package test_suite :: Package unit_tests :: Package _pipe_control :: Module test_value
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._pipe_control.test_value

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-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 unittest import TestCase 
 24   
 25  # relax module imports. 
 26  from pipe_control import pipes, value 
 27  from test_suite.unit_tests.value_testing_base import Value_base_class 
 28   
 29   
 30   
31 -class Test_value(Value_base_class, TestCase):
32 """Unit tests for the functions of the 'pipe_control.value' module.""" 33 34 # Place the pipe_control.value module into the class namespace. 35 value_fns = value 36 37
38 - def test_partition_params1(self):
39 """First test of the pipe_control.value.partition_params() function.""" 40 41 # Set the current data pipe to 'mf'. 42 pipes.switch('mf') 43 44 # The parameters and values. 45 param = ['s2'] 46 val = [0.8] 47 48 # Partition. 49 spin_params, spin_values, other_params, other_values = value.partition_params(val, param) 50 51 # Tests. 52 self.assertEqual(spin_params, ['s2']) 53 self.assertEqual(spin_values, [0.8]) 54 self.assertEqual(other_params, []) 55 self.assertEqual(other_values, [])
56 57
58 - def test_partition_params2(self):
59 """Second test of the pipe_control.value.partition_params() function.""" 60 61 # Set the current data pipe to 'mf'. 62 pipes.switch('mf') 63 64 # The parameters and values. 65 param = ['Dx'] 66 val = [1e7] 67 68 # Partition. 69 spin_params, spin_values, other_params, other_values = value.partition_params(val, param) 70 71 # Tests. 72 self.assertEqual(spin_params, []) 73 self.assertEqual(spin_values, []) 74 self.assertEqual(other_params, ['Dx']) 75 self.assertEqual(other_values, [1e7])
76 77
78 - def test_partition_params3(self):
79 """Third test of the pipe_control.value.partition_params() function.""" 80 81 # Set the current data pipe to 'mf'. 82 pipes.switch('mf') 83 84 # The parameters and values. 85 param = ['Dx', 's2'] 86 val = [1e7, 0.8] 87 88 # Partition. 89 spin_params, spin_values, other_params, other_values = value.partition_params(val, param) 90 91 # Tests. 92 self.assertEqual(spin_params, ['s2']) 93 self.assertEqual(spin_values, [0.8]) 94 self.assertEqual(other_params, ['Dx']) 95 self.assertEqual(other_values, [1e7])
96 97
98 - def test_partition_params4(self):
99 """Forth test of the pipe_control.value.partition_params() function.""" 100 101 # Set the current data pipe to 'mf'. 102 pipes.switch('mf') 103 104 # The parameters and values. 105 param = ['Dx', 's2', 'csa'] 106 val = [1e7, 0.8, -160e-6] 107 108 # Partition. 109 spin_params, spin_values, other_params, other_values = value.partition_params(val, param) 110 111 # Tests. 112 self.assertEqual(spin_params, ['s2', 'csa']) 113 self.assertEqual(spin_values, [0.8, -160e-6]) 114 self.assertEqual(other_params, ['Dx']) 115 self.assertEqual(other_values, [1e7])
116 117
118 - def test_partition_params5(self):
119 """Fifth test of the pipe_control.value.partition_params() function.""" 120 121 # Set the current data pipe to 'mf'. 122 pipes.switch('mf') 123 124 # The parameters and values. 125 param = ['Dpar', 's2', 'Dper', 'csa', 'theta'] 126 val = [1e7, 0.8, 2e7, -160e-6, 0.13] 127 128 # Partition. 129 spin_params, spin_values, other_params, other_values = value.partition_params(val, param) 130 131 # Tests. 132 self.assertEqual(spin_params, ['s2', 'csa']) 133 self.assertEqual(spin_values, [0.8, -160e-6]) 134 self.assertEqual(other_params, ['Dpar', 'Dper', 'theta']) 135 self.assertEqual(other_values, [1e7, 2e7, 0.13])
136 137
138 - def test_partition_params6(self):
139 """Sixth test of the pipe_control.value.partition_params() function.""" 140 141 # Set the current data pipe to 'mf'. 142 pipes.switch('mf') 143 144 # The parameters and values. 145 param = [] 146 val = [] 147 148 # Partition. 149 spin_params, spin_values, other_params, other_values = value.partition_params(val, param) 150 151 # Tests. 152 self.assertEqual(spin_params, []) 153 self.assertEqual(spin_values, []) 154 self.assertEqual(other_params, []) 155 self.assertEqual(other_values, [])
156