Author: bugman Date: Wed Mar 27 15:22:11 2013 New Revision: 19236 URL: http://svn.gna.org/viewcvs/relax?rev=19236&view=rev Log: Ported r8686 from the old relax_disp branch into the new branch. The commands used were: svn merge -r8685:8686 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/relax_disp/specific_fns/@r18123 specific_analyses svn merge -r8685:8686 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/relax_disp/test_suite/@r18123 test_suite The changes to the prompt package were manually ported to the user_functions package. ..... r8686 | semor | 2009-01-27 22:47:00 +0100 (Tue, 27 Jan 2009) | 5 lines Changed paths: M /branches/relax_disp/prompt/relax_disp.py M /branches/relax_disp/specific_fns/relax_disp.py M /branches/relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py Added more unit tests and tried to debug what was uncovered by these tests. Still more work is needed for debugging... ..... Modified: branches/relax_disp/specific_analyses/relax_disp.py branches/relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py branches/relax_disp/user_functions/relax_disp.py Modified: branches/relax_disp/specific_analyses/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp.py?rev=19236&r1=19235&r2=19236&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp.py (original) +++ branches/relax_disp/specific_analyses/relax_disp.py Wed Mar 27 15:22:11 2013 @@ -241,7 +241,7 @@ return results[result_index] - def calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=0, int_ref=0): + def calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=0.0, int_ref=0.0): """Calculate the effective transversal relaxation rate from the peak intensities. The equation depends on the experiment type chosen, either 'cpmg' or 'r1rho'. @@ -600,7 +600,7 @@ spin.dw = param_vector[5] - def exp_type(self, exp='cpmg'): + def exp_type(self, exp_type='cpmg'): """Function for selecting the relaxation dispersion experiment type performed. @keyword exp: The relaxation dispersion experiment type. Can be one of 'cpmg' or 'r1rho'. @type exp: str @@ -622,18 +622,18 @@ raise RelaxNoSequenceError # CPMG relaxation dispersion experiments. - if exp == 'cpmg': + if exp_type == 'cpmg': print "CPMG relaxation dispersion experiments." cdp.exp_type = 'cpmg' # R1rho relaxation dispersion experiments. - elif exp == 'r1rho': + elif exp_type == 'r1rho': print "R1rho relaxation dispersion experiments." cdp.exp_type = 'r1rho' # Invalid relaxation dispersion experiment. else: - raise RelaxError, "The relaxation dispersion experiment '" + exp + "' is invalid." + raise RelaxError, "The relaxation dispersion experiment '" + exp_type + "' is invalid." def grid_search(self, lower=None, upper=None, inc=None, constraints=True, verbosity=1, sim_index=None): Modified: branches/relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py?rev=19236&r1=19235&r2=19236&view=diff ============================================================================== --- branches/relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py (original) +++ branches/relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py Wed Mar 27 15:22:11 2013 @@ -26,7 +26,7 @@ # relax module imports. from prompt.relax_disp import Relax_disp -from relax_errors import RelaxNoneNumError, RelaxStrError +from relax_errors import RelaxNoneNumError, RelaxNumError, RelaxStrError # Unit test imports. from data_types import DATA_TYPES @@ -38,6 +38,70 @@ # Instantiate the user function class. relax_disp_fns = Relax_disp(fake_relax.fake_instance()) + + + def test_relax_calc_r2eff_argfail_exp_type(self): + """The exp_type arg test of the relax_disp.relax_calc_r2eff() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the str arguments, and skip them. + if data[0] == 'str': + continue + + # The argument test. + self.assertRaises(RelaxStrError, self.relax_disp_fns.calc_r2eff, exp_type=data[1]) + + def test_relax_calc_r2eff_argfail_id(self): + """The id arg test of the relax_disp.relax_calc_r2eff() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the str arguments, and skip them. + if data[0] == 'str': + continue + + # The argument test. + self.assertRaises(RelaxStrError, self.relax_disp_fns.calc_r2eff, id=data[1]) + + + def test_relax_calc_r2eff_argfail_delayT(self): + """The delayT arg test of the relax_disp.relax_calc_r2eff() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the float, int and None arguments, and skip them. + if data[0] == 'float' or data[0] == 'int' or data[0] == 'None': + continue + + # The argument test. + self.assertRaises(RelaxNoneNumError, self.relax_disp_fns.calc_r2eff, delayT=data[1]) + + + def test_relax_calc_r2eff_argfail_int_cpmg(self): + """The int_cpmg arg test of the relax_disp.relax_calc_r2eff() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the float, int and None arguments, and skip them. + if data[0] == 'float' or data[0] == 'int': + continue + + # The argument test. + self.assertRaises(RelaxNumError, self.relax_disp_fns.calc_r2eff, int_cpmg=data[1]) + + + def test_relax_calc_r2eff_argfail_int_ref(self): + """The int_ref arg test of the relax_disp.relax_calc_r2eff() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the float, int and None arguments, and skip them. + if data[0] == 'float' or data[0] == 'int': + continue + + # The argument test. + self.assertRaises(RelaxNumError, self.relax_disp_fns.calc_r2eff, int_ref=data[1]) def test_relax_cpmg_delayT_argfail_id(self): @@ -92,8 +156,8 @@ self.assertRaises(RelaxStrError, self.relax_disp_fns.cpmg_frq, spectrum_id=data[1]) - def test_relax_exp_type_argfail_exp(self): - """The exp arg test of the relax_disp.exp_type() user function.""" + def test_relax_exp_type_argfail_exp_type(self): + """The exp_type arg test of the relax_disp.exp_type() user function.""" # Loop over the data types. for data in DATA_TYPES: @@ -102,7 +166,7 @@ continue # The argument test. - self.assertRaises(RelaxStrError, self.relax_disp_fns.exp_type, exp=data[1]) + self.assertRaises(RelaxStrError, self.relax_disp_fns.exp_type, exp_type=data[1]) def test_relax_select_model_argfail_model(self): Modified: branches/relax_disp/user_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/relax_disp.py?rev=19236&r1=19235&r2=19236&view=diff ============================================================================== --- branches/relax_disp/user_functions/relax_disp.py (original) +++ branches/relax_disp/user_functions/relax_disp.py Wed Mar 27 15:22:11 2013 @@ -43,7 +43,7 @@ uf.title = "Calculate the effective transversal relaxation rate from the peak intensities." uf.title_short = "R2eff calculation." uf.add_keyarg( - name = "exp", + name = "exp_type", default = "cpmg", py_type = "str", desc_short = "experiment type", @@ -154,7 +154,7 @@ uf.title = "Select the type of relaxation dispersion experiments to analyse." uf.title_short = "Relaxation dispersion type selection." uf.add_keyarg( - name = "exp", + name = "exp_type", default = "cpmg", py_type = "str", desc_short = "experiment type", @@ -167,7 +167,7 @@ uf.desc.append(Desc_container("Prompt examples")) uf.desc[-1].add_paragraph("To pick the experiment type 'cpmg' for all selected spins, type one of:") uf.desc[-1].add_prompt("relax> relax_disp.exp_type('cpmg')") -uf.desc[-1].add_prompt("relax> relax_disp.exp_type(exp='cpmg')") +uf.desc[-1].add_prompt("relax> relax_disp.exp_type(exp_type='cpmg')") uf.backend = relax_disp_obj._exp_type uf.menu_text = "&exp_type" uf.wizard_size = (800, 500)