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):