Author: bugman Date: Fri Jul 18 11:05:51 2014 New Revision: 24565 URL: http://svn.gna.org/viewcvs/relax?rev=24565&view=rev Log: Created the parameter object infrastructure for adding the grid search lower and upper bounds. The _add() method now accepts the grid_lower and grid_upper keyword arguments, which can be either values or functions. These are then stored in the _grid_lower and _grid_upper class dictionaries. The public methods grid_lower() and grid_upper() have been added to return the value corresponding to the given parameter. Modified: branches/zooming_grid_search/specific_analyses/parameter_object.py Modified: branches/zooming_grid_search/specific_analyses/parameter_object.py URL: http://svn.gna.org/viewcvs/relax/branches/zooming_grid_search/specific_analyses/parameter_object.py?rev=24565&r1=24564&r2=24565&view=diff ============================================================================== --- branches/zooming_grid_search/specific_analyses/parameter_object.py (original) +++ branches/zooming_grid_search/specific_analyses/parameter_object.py Fri Jul 18 11:05:51 2014 @@ -59,6 +59,8 @@ self._py_types = {} self._conv_factor = {} self._grace_string = {} + self._grid_lower = {} + self._grid_upper = {} self._set = {} self._err = {} self._sim = {} @@ -92,7 +94,7 @@ return cls._instance - def _add(self, name, scope=None, string=None, default=None, units=None, desc=None, py_type=None, set='all', conv_factor=None, grace_string=None, err=False, sim=False): + def _add(self, name, scope=None, string=None, default=None, units=None, desc=None, py_type=None, set='all', conv_factor=None, grid_lower=None, grid_upper=None, grace_string=None, err=False, sim=False): """Add a parameter to the list. @param name: The name of the parameter. This will be used as the variable name. @@ -113,6 +115,10 @@ @type set: str @keyword conv_factor: The factor of conversion between different parameter units. @type conv_factor: None, float or func + @keyword grid_lower: The lower bound for the grid search. + @type grid_lower: int or function + @keyword grid_upper: The upper bound for the grid search. + @type grid_upper: int or function @keyword grace_string: The string used for the axes in Grace plots of the data. @type grace_string: None or str @keyword err: A flag which if True indicates that the parameter name + '_err' error data structure can exist. @@ -141,6 +147,8 @@ self._conv_factor[name] = conv_factor self._err[name] = err self._sim[name] = sim + self._grid_lower[name] = grid_lower + self._grid_upper[name] = grid_upper # The parameter string. if string: @@ -524,6 +532,46 @@ return self._err[name] + def grid_lower(self, name): + """Return the default lower grid bound for the parameter. + + @param name: The name of the parameter. + @type name: str + @return: The lower bound for the grid search. + @rtype: int + """ + + # Parameter check. + self.check_param(name) + + # Call any function or method. + if isinstance(self._grid_lower[name], FunctionType) or isinstance(self._grid_lower[name], MethodType): + return self._grid_lower[name]() + + # Return the value. + return self._grid_lower[name] + + + def grid_upper(self, name): + """Return the default upper grid bound for the parameter. + + @param name: The name of the parameter. + @type name: str + @return: The upper bound for the grid search. + @rtype: int + """ + + # Parameter check. + self.check_param(name) + + # Call any function or method. + if isinstance(self._grid_upper[name], FunctionType) or isinstance(self._grid_upper[name], MethodType): + return self._grid_upper[name]() + + # Return the value. + return self._grid_upper[name] + + def grace_string(self, name): """Return the Grace string for the parameter.