Author: bugman Date: Sun Nov 29 15:20:13 2009 New Revision: 10013 URL: http://svn.gna.org/viewcvs/relax?rev=10013&view=rev Log: Created the common API method _set_param_values_spin(). A number of modules are now using this method. Modified: 1.3/specific_fns/api_common.py 1.3/specific_fns/consistency_tests.py 1.3/specific_fns/jw_mapping.py 1.3/specific_fns/relax_fit.py Modified: 1.3/specific_fns/api_common.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/api_common.py?rev=10013&r1=10012&r2=10013&view=diff ============================================================================== --- 1.3/specific_fns/api_common.py (original) +++ 1.3/specific_fns/api_common.py Sun Nov 29 15:20:13 2009 @@ -27,6 +27,7 @@ from copy import deepcopy # relax module imports. +import arg_check from generic_fns.mol_res_spin import count_spins, exists_mol_res_spin_data, return_spin, spin_loop from relax_errors import RelaxError, RelaxLenError, RelaxNoSequenceError @@ -329,6 +330,40 @@ inc = inc + 1 + def _set_param_values_spin(self, param=None, value=None, spin_id=None, force=True): + """Set the spin specific parameter values. + + @keyword param: The parameter name. + @type param: str + @keyword value: The parameter value. + @type value: number + @keyword spin_id: The spin identification string, only used for spin specific parameters. + @type spin_id: None or str + @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. + @type force: bool + """ + + # Checks. + arg_check.is_str(param, 'parameter name') + arg_check.is_num(value, 'parameter value') + + # Get the object's name. + obj_name = self.return_data_name(param) + + # Is the parameter is valid? + if not obj_name: + raise RelaxError("The parameter '%s' is not valid for this data pipe type." % param) + + # Spin loop. + for spin in spin_loop(spin_id): + # Skip deselected spins. + if not spin.select: + continue + + # Set the parameter. + setattr(spin, obj_name, value) + + def _set_selected_sim_spin(self, model_info, select_sim): """Set the simulation selection flag (spin system specific). Modified: 1.3/specific_fns/consistency_tests.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/consistency_tests.py?rev=10013&r1=10012&r2=10013&view=diff ============================================================================== --- 1.3/specific_fns/consistency_tests.py (original) +++ 1.3/specific_fns/consistency_tests.py Sun Nov 29 15:20:13 2009 @@ -25,7 +25,8 @@ from re import search # relax module imports. -from specific_fns.api_base import API_base +from api_base import API_base +from api_common import API_common from generic_fns.mol_res_spin import exists_mol_res_spin_data, return_spin, spin_loop from generic_fns import pipes from maths_fns.consistency_tests import Consistency @@ -33,8 +34,15 @@ from relax_errors import RelaxError, RelaxFuncSetupError, RelaxNoSequenceError, RelaxNoValueError, RelaxProtonTypeError, RelaxSpinTypeError -class Consistency_tests(API_base): +class Consistency_tests(API_base, API_common): """Class containing functions specific to consistency testing.""" + + def __init__(self): + """Initialise the class by placing API_common methods into the API.""" + + # Place methods into the API. + self.set_param_values = self._set_param_values_spin + def _set_frq(self, frq=None): """Function for selecting which relaxation data to use in the consistency tests.""" Modified: 1.3/specific_fns/jw_mapping.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/jw_mapping.py?rev=10013&r1=10012&r2=10013&view=diff ============================================================================== --- 1.3/specific_fns/jw_mapping.py (original) +++ 1.3/specific_fns/jw_mapping.py Sun Nov 29 15:20:13 2009 @@ -24,7 +24,8 @@ from re import search # relax module imports. -from specific_fns.api_base import API_base +from api_base import API_base +from api_common import API_common from generic_fns.mol_res_spin import exists_mol_res_spin_data, return_spin, spin_loop from generic_fns import pipes from maths_fns.jw_mapping import Mapping @@ -32,8 +33,15 @@ from relax_errors import RelaxError, RelaxFuncSetupError, RelaxNoSequenceError, RelaxNoValueError, RelaxProtonTypeError, RelaxSpinTypeError -class Jw_mapping(API_base): +class Jw_mapping(API_base, API_common): """Class containing functions specific to reduced spectral density mapping.""" + + def __init__(self): + """Initialise the class by placing API_common methods into the API.""" + + # Place methods into the API. + self.set_param_values = self._set_param_values_spin + def _set_frq(self, frq=None): """Function for selecting which relaxation data to use in the J(w) mapping.""" Modified: 1.3/specific_fns/relax_fit.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/relax_fit.py?rev=10013&r1=10012&r2=10013&view=diff ============================================================================== --- 1.3/specific_fns/relax_fit.py (original) +++ 1.3/specific_fns/relax_fit.py Sun Nov 29 15:20:13 2009 @@ -31,8 +31,9 @@ from re import match, search # relax module imports. +from api_base import API_base +from api_common import API_common from dep_check import C_module_exp_fn -from specific_fns.api_base import API_base from generic_fns import pipes from generic_fns.mol_res_spin import exists_mol_res_spin_data, generate_spin_id, return_spin, spin_loop from relax_errors import RelaxError, RelaxFuncSetupError, RelaxLenError, RelaxNoModelError, RelaxNoSequenceError @@ -42,8 +43,15 @@ from maths_fns.relax_fit import setup, func, dfunc, d2func, back_calc_I -class Relax_fit(API_base): +class Relax_fit(API_base, API_common): """Class containing functions for relaxation curve fitting.""" + + def __init__(self): + """Initialise the class by placing API_common methods into the API.""" + + # Place methods into the API. + self.set_param_values = self._set_param_values_spin + def _assemble_param_vector(self, spin=None, sim_index=None): """Assemble the exponential curve parameter vector (as a numpy array).