Author: bugman Date: Tue Jan 15 14:40:06 2008 New Revision: 4745 URL: http://svn.gna.org/viewcvs/relax?rev=4745&view=rev Log: Shifted the grid ops tests into the test_grid_ops() base class function. Modified: 1.3/specific_fns/base_class.py 1.3/specific_fns/model_free/mf_minimise.py Modified: 1.3/specific_fns/base_class.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/base_class.py?rev=4745&r1=4744&r2=4745&view=diff ============================================================================== --- 1.3/specific_fns/base_class.py (original) +++ 1.3/specific_fns/base_class.py Tue Jan 15 14:40:06 2008 @@ -410,3 +410,36 @@ # Return the array. return spin.select_sim + + + def test_grid_ops(self, lower=None, upper=None, inc=None, n=n): + """Function for testing that the grid search options are reasonable. + + @param lower: The lower bounds of the grid search which must be equal to the number of + parameters in the model. + @type lower: array of numbers + @param upper: The upper bounds of the grid search which must be equal to the number of + parameters in the model. + @type upper: array of numbers + @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. + @type inc: array of int + @param n: The number of parameters in the model. + @type n: int + """ + + # Lower bounds test. + if lower != None: + if len(lower) != n: + raise RelaxLenError, ('lower bounds', n) + + # Upper bounds. + if upper != None: + if len(upper) != n: + raise RelaxLenError, ('upper bounds', n) + + # Increment. + if type(inc) == list: + if len(inc) != n: + raise RelaxLenError, ('increment', n) Modified: 1.3/specific_fns/model_free/mf_minimise.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/model_free/mf_minimise.py?rev=4745&r1=4744&r2=4745&view=diff ============================================================================== --- 1.3/specific_fns/model_free/mf_minimise.py (original) +++ 1.3/specific_fns/model_free/mf_minimise.py Tue Jan 15 14:40:06 2008 @@ -239,22 +239,11 @@ if n == 0: print "Cannot run a grid search on a model with zero parameters, skipping the grid search." - # Lower bounds. - if lower != None: - if len(lower) != n: - raise RelaxLenError, ('lower bounds', n) - - # Upper bounds. - if upper != None: - if len(upper) != n: - raise RelaxLenError, ('upper bounds', n) - - # Increment. - if type(inc) == list: - if len(inc) != n: - raise RelaxLenError, ('increment', n) - inc = inc - elif type(inc) == int: + # Test the grid search options. + self.test_grid_ops(lower=lower, upper=upper, inc=inc, n=n) + + # If inc is a single int, convert it into an array of that value. + if type(inc) == int: temp = [] for j in xrange(n): temp.append(inc)