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

Source Code for Module test_suite.unit_tests._generic_fns.test_value

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