Package lib :: Module optimisation
[hide private]
[frames] | no frames]

Source Code for Module lib.optimisation

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2004-2014 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  # Module docstring. 
23  """Auxiliary functions for optimisation.""" 
24   
25   
26  # relax module imports. 
27  from lib.errors import RelaxLenError 
28   
29   
30 -def test_grid_ops(lower=None, upper=None, inc=None, n=None):
31 """Test that the grid search options are reasonable. 32 33 @param lower: The lower bounds of the grid search which must be equal to the number of parameters in the model. 34 @type lower: array of numbers 35 @param upper: The upper bounds of the grid search which must be equal to the number of parameters in the model. 36 @type upper: array of numbers 37 @param inc: The increments for each dimension of the space for the grid search. The number of elements in the array must equal to the number of parameters in the model. 38 @type inc: array of int 39 @param n: The number of parameters in the model. 40 @type n: int 41 """ 42 43 # Lower bounds test. 44 if lower != None: 45 if len(lower) != n: 46 raise RelaxLenError('lower bounds', n) 47 48 # Upper bounds. 49 if upper != None: 50 if len(upper) != n: 51 raise RelaxLenError('upper bounds', n) 52 53 # Increment. 54 if isinstance(inc, list): 55 if len(inc) != n: 56 raise RelaxLenError('increment', n)
57