Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2008-2009,2012,2014,2019 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 prompt.interpreter import Interpreter 27 from lib.errors import RelaxError, RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxIntListIntError, RelaxListNumError, RelaxStrError 28 from test_suite.unit_tests.minimisation_testing_base import Minimisation_base_class 29 30 # Unit test imports. 31 from test_suite.unit_tests._prompt.data_types import DATA_TYPES 32 3335 """Unit tests for the functions of the 'prompt.minimisation' module.""" 3626738 """Set up the test case class for the system tests.""" 39 40 # Execute the base __init__ methods. 41 super(Test_minimisation, self).__init__(methodName) 42 43 # Load the interpreter. 44 self.interpreter = Interpreter(show_script=False, raise_relax_error=True) 45 self.interpreter.populate_self() 46 self.interpreter.on(verbose=False) 47 48 # Alias the user function class. 49 self.minimisation_fns = self.interpreter.minimise50 5153 """The verbosity arg test of the minimise.calculate() user function.""" 54 55 # Loop over the data types. 56 for data in DATA_TYPES: 57 # Catch the int and bin arguments, and skip them. 58 if data[0] == 'int' or data[0] == 'bin': 59 continue 60 61 # The argument test. 62 self.assertRaises(RelaxIntError, self.minimisation_fns.calculate, verbosity=data[1])63 6466 """The lower arg test of the minimise.grid_search() user function.""" 67 68 # Loop over the data types. 69 for data in DATA_TYPES: 70 # Catch the None and int, float, and number list arguments arguments, and skip them. 71 if data[0] == 'None' or data[0] == 'int list' or data[0] == 'float list' or data[0] == 'number list': 72 continue 73 74 # The argument test. 75 self.assertRaises(RelaxListNumError, self.minimisation_fns.grid_search, lower=data[1])76 7779 """The upper arg test of the minimise.grid_search() user function.""" 80 81 # Loop over the data types. 82 for data in DATA_TYPES: 83 # Catch the None and int, float, and number list arguments arguments, and skip them. 84 if data[0] == 'None' or data[0] == 'int list' or data[0] == 'float list' or data[0] == 'number list': 85 continue 86 87 # The argument test. 88 self.assertRaises(RelaxListNumError, self.minimisation_fns.grid_search, upper=data[1])89 9092 """The inc arg test of the minimise.grid_search() user function.""" 93 94 # Loop over the data types. 95 for data in DATA_TYPES: 96 # Catch the None, bin, int, and interger list arguments, and skip them. 97 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list' or data[0] == 'none list': 98 continue 99 100 # The argument test. 101 self.assertRaises(RelaxIntListIntError, self.minimisation_fns.grid_search, inc=data[1])102 103105 """The constraints arg test of the minimise.grid_search() user function.""" 106 107 # Loop over the data types. 108 for data in DATA_TYPES: 109 # Catch the bool arguments, and skip them. 110 if data[0] == 'bool': 111 continue 112 113 # The argument test. 114 self.assertRaises(RelaxBoolError, self.minimisation_fns.grid_search, constraints=data[1])115 116118 """The verbosity arg test of the minimise.grid_search() user function.""" 119 120 # Loop over the data types. 121 for data in DATA_TYPES: 122 # Catch the int and bin arguments, and skip them. 123 if data[0] == 'int' or data[0] == 'bin': 124 continue 125 126 # The argument test. 127 self.assertRaises(RelaxIntError, self.minimisation_fns.grid_search, verbosity=data[1])128 129131 """The test of a bad keyword argument in the minimise.execute() user function.""" 132 133 # Loop over the data types. 134 for data in DATA_TYPES: 135 # The argument test. 136 self.assertRaises(RelaxError, self.minimisation_fns.execute, 'Newton', step_tol=data[1])137 138140 """The min_algor arg test of the minimise.execute() user function.""" 141 142 # Loop over the data types. 143 for data in DATA_TYPES: 144 # Catch the str argument, and skip it. 145 if data[0] == 'str': 146 continue 147 148 # The argument test. 149 self.assertRaises(RelaxStrError, self.minimisation_fns.execute, data[1])150 151153 """The line_search arg test of the minimise.execute() user function.""" 154 155 # Loop over the data types. 156 for data in DATA_TYPES: 157 # Catch the None and str arguments, and skip them. 158 if data[0] == 'None' or data[0] == 'str': 159 continue 160 161 # The argument test. 162 self.assertRaises(RelaxStrError, self.minimisation_fns.execute, 'Newton', line_search=data[1])163 164166 """The hessian_mod arg test of the minimise.execute() user function.""" 167 168 # Loop over the data types. 169 for data in DATA_TYPES: 170 # Catch the None and str arguments, and skip them. 171 if data[0] == 'None' or data[0] == 'str': 172 continue 173 174 # The argument test. 175 self.assertRaises(RelaxStrError, self.minimisation_fns.execute, 'Newton', hessian_mod=data[1])176 177179 """The hessian_type arg test of the minimise.execute() user function.""" 180 181 # Loop over the data types. 182 for data in DATA_TYPES: 183 # Catch the None and str arguments, and skip them. 184 if data[0] == 'None' or data[0] == 'str': 185 continue 186 187 # The argument test. 188 self.assertRaises(RelaxStrError, self.minimisation_fns.execute, 'Newton', hessian_type=data[1])189 190192 """The func_tol arg test of the minimise.execute() user function.""" 193 194 # Loop over the data types. 195 for data in DATA_TYPES: 196 # Catch the float, bin, and int arguments, and skip them. 197 if data[0] == 'float': 198 continue 199 200 # The argument test. 201 self.assertRaises(RelaxFloatError, self.minimisation_fns.execute, 'Newton', func_tol=data[1])202 203205 """The grad_tol arg test of the minimise.execute() user function.""" 206 207 # Loop over the data types. 208 for data in DATA_TYPES: 209 # Catch the None, float, bin, and int arguments, and skip them. 210 if data[0] == 'None' or data[0] == 'float': 211 continue 212 213 # The argument test. 214 self.assertRaises(RelaxFloatError, self.minimisation_fns.execute, 'Newton', grad_tol=data[1])215 216218 """The max_iter arg test of the minimise.execute() user function.""" 219 220 # Loop over the data types. 221 for data in DATA_TYPES: 222 # Catch the bin and int arguments, and skip them. 223 if data[0] == 'bin' or data[0] == 'int': 224 continue 225 226 # The argument test. 227 self.assertRaises(RelaxIntError, self.minimisation_fns.execute, 'Newton', max_iter=data[1])228 229231 """The constraints arg test of the minimise.execute() user function.""" 232 233 # Loop over the data types. 234 for data in DATA_TYPES: 235 # Catch the bool arguments, and skip them. 236 if data[0] == 'bool': 237 continue 238 239 # The argument test. 240 self.assertRaises(RelaxBoolError, self.minimisation_fns.execute, 'Newton', constraints=data[1])241 242244 """The scaling arg test of the minimise.execute() user function.""" 245 246 # Loop over the data types. 247 for data in DATA_TYPES: 248 # Catch the bool arguments, and skip them. 249 if data[0] == 'bool': 250 continue 251 252 # The argument test. 253 self.assertRaises(RelaxBoolError, self.minimisation_fns.execute, 'Newton', scaling=data[1])254 255257 """The verbosity arg test of the minimise.execute() user function.""" 258 259 # Loop over the data types. 260 for data in DATA_TYPES: 261 # Catch the bin and int arguments, and skip them. 262 if data[0] == 'bin' or data[0] == 'int': 263 continue 264 265 # The argument test. 266 self.assertRaises(RelaxIntError, self.minimisation_fns.execute, 'Newton', verbosity=data[1])
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 8 10:44:45 2024 | http://epydoc.sourceforge.net |