Hi, I have been struggling to fix a bug with the unit test for a while... Presently, the unit test for relaxation dispersion fails with the following 3 errors: ====================================================================== ERROR: The delayT arg test of the relax_disp.relax_calc_r2eff() user function. ---------------------------------------------------------------------- relax> relax_disp.calc_r2eff(exp_type='cpmg', id=None, delayT=0, int_cpmg=1.0, int_ref=1.0) Traceback (most recent call last): File "/home/semor/pse-4/collaborations/relax/relax-1.3--relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py", line 78, in test_relax_calc_r2eff_argfail_delayT self.assertRaises(RelaxNoneNumError, self.relax_disp_fns.calc_r2eff, delayT=data[1]) File "/usr/lib/python2.5/unittest.py", line 320, in failUnlessRaises callableObj(*args, **kwargs) File "/home/semor/pse-4/collaborations/relax/relax-1.3--relax_disp/prompt/relax_disp.py", line 101, in calc_r2eff raise RelaxStrError, ('experiment identification string', id) RelaxStrError: RelaxError: The experiment identification string argument None must be a string. ====================================================================== ERROR: The int_cpmg arg test of the relax_disp.relax_calc_r2eff() user function. ---------------------------------------------------------------------- relax> relax_disp.calc_r2eff(exp_type='cpmg', id=None, delayT=None, int_cpmg=0, int_ref=1.0) Traceback (most recent call last): File "/home/semor/pse-4/collaborations/relax/relax-1.3--relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py", line 91, in test_relax_calc_r2eff_argfail_int_cpmg self.assertRaises(RelaxNumError, self.relax_disp_fns.calc_r2eff, int_cpmg=data[1]) File "/usr/lib/python2.5/unittest.py", line 320, in failUnlessRaises callableObj(*args, **kwargs) File "/home/semor/pse-4/collaborations/relax/relax-1.3--relax_disp/prompt/relax_disp.py", line 101, in calc_r2eff raise RelaxStrError, ('experiment identification string', id) RelaxStrError: RelaxError: The experiment identification string argument None must be a string. ====================================================================== ERROR: The int_ref arg test of the relax_disp.relax_calc_r2eff() user function. ---------------------------------------------------------------------- relax> relax_disp.calc_r2eff(exp_type='cpmg', id=None, delayT=None, int_cpmg=1.0, int_ref=0) Traceback (most recent call last): File "/home/semor/pse-4/collaborations/relax/relax-1.3--relax_disp/test_suite/unit_tests/_prompt/test_relax_disp.py", line 104, in test_relax_calc_r2eff_argfail_int_ref self.assertRaises(RelaxNumError, self.relax_disp_fns.calc_r2eff, int_ref=data[1]) File "/usr/lib/python2.5/unittest.py", line 320, in failUnlessRaises callableObj(*args, **kwargs) File "/home/semor/pse-4/collaborations/relax/relax-1.3--relax_disp/prompt/relax_disp.py", line 101, in calc_r2eff raise RelaxStrError, ('experiment identification string', id) RelaxStrError: RelaxError: The experiment identification string argument None must be a string. As you can see, the error seems to be the same for the three parts. However, this code for the 'relax_disp.calc_r2eff' unit tests is similar to that used for 'relax_disp.cpmg_delayT' where this problem did not arise. Moreover, of the 5 argument tests for the calc_r2eff() function, the 'id' argument (which is related to the error message) test passes, as well as the 'exp_type' argument test... Only the 'delayT', 'int_cpmg' and 'int_ref' argument tests fail... Do you have an idea about the possible cause for these errors ??? Thanks for helping me out ! Séb :) sebastien.morin.1@xxxxxxxxx wrote:
Author: semor Date: Tue Jan 27 23:11:53 2009 New Revision: 8687 URL: http://svn.gna.org/viewcvs/relax?rev=8687&view=rev Log: A few fixes based on the unit tests problems. Modified: branches/relax_disp/prompt/relax_disp.py branches/relax_disp/specific_fns/relax_disp.py Modified: branches/relax_disp/prompt/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/prompt/relax_disp.py?rev=8687&r1=8686&r2=8687&view=diff ============================================================================== --- branches/relax_disp/prompt/relax_disp.py (original) +++ branches/relax_disp/prompt/relax_disp.py Tue Jan 27 23:11:53 2009 @@ -47,7 +47,7 @@ self.__relax__ = relax - def calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=0.0, int_ref=0.0): + def calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=0.0, int_ref=1.0): """Calculate the effective transversal relaxation rate from the peak intensities. THIS FUNCTION IS NOT WRITTEN YET. @@ -105,11 +105,11 @@ raise RelaxNoneNumError, ('CPMG constant time delay (T)', delayT) # The CPMG peak intensity. - if type(int_cpmg) != float and type(delayT) != int: + if type(int_cpmg) != float and type(int_cpmg) != int: raise RelaxNumError, ('int_cpmg', int_cpmg) # The reference peak intensity. - if type(int_ref) != float and type(delayT) != int: + if type(int_ref) != float and type(int_ref) != int: raise RelaxNumError, ('int_ref', int_ref) # Execute the functional code. Modified: branches/relax_disp/specific_fns/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_fns/relax_disp.py?rev=8687&r1=8686&r2=8687&view=diff ============================================================================== --- branches/relax_disp/specific_fns/relax_disp.py (original) +++ branches/relax_disp/specific_fns/relax_disp.py Tue Jan 27 23:11:53 2009 @@ -241,7 +241,7 @@ return results[result_index] - def calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=0.0, int_ref=0.0): + def calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=0.0, int_ref=1.0): """Calculate the effective transversal relaxation rate from the peak intensities. The equation depends on the experiment type chosen, either 'cpmg' or 'r1rho'. @@ -258,10 +258,20 @@ @type int_ref: float """ - if exp_type == 'cpmg': + # Avoid division by zero. + if int_ref == 0: + raise RelaxError, "The reference peak intensity should not have a value of 0 (zero)" + + # Avoid other inmpossible mathematical situation. + if int_cpmg == 0: + raise RelaxError, "The CPMG peak intensity should not have a value of 0 (zero)" + + if delayT == 0: + raise RelaxError, "The CPMG constant time delay (T) should not have a value of 0 (zero)" + + if exp_type == 'cpmg' and delayT != None: r2eff = - ( 1 / delayT ) * log ( int_cpmg / int_ref ) - - return r2eff + return r2eff def cpmg_frq(self, cpmg_frq=None, spectrum_id=None): _______________________________________________ relax (http://nmr-relax.com) This is the relax-commits mailing list relax-commits@xxxxxxx To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits