mailRe: r8687 - in /branches/relax_disp: prompt/relax_disp.py specific_fns/relax_disp.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on January 28, 2009 - 18:21:
Ah, I've had a closer look at your tests and noticed something
missing.  There is a data type called 'bin' which included 0 and 1.
This should also be caught on the lines such as:

if data[0] == 'float' or data[0] == 'int':

This is the source of the problem.

Regards,

Edward


On Wed, Jan 28, 2009 at 3:49 PM, Sébastien Morin
<sebastien.morin.1@xxxxxxxxx> wrote:
Hi,

The problem is now solved (r8696).

However, 'delayT', 'int_cpmg' and 'int_ref' should not have a value of 0
(for obvious mathematical reasons). Hence, a check is made by the code
in 'specific_fns/relax_disp.calc_r2eff()'. However, because data in
'data_types' include 0, this throws an error which I would like to avoid
for the unit test to pass...

Is there a way to catch this error and avoid the unit test to fail ? In
fact, this error when data in data_types is 0 is normal and wanted so
the test should pass...

Regards,


Séb  :)


Edward d'Auvergne wrote:
Hi,

The problem here is quite simple, the relax_disp.calc_r2eff() user
function must have the id arg supplied.  So for these unit tests, just
set the id keyword arg to any random string.  The exp_type arg is ok,
because it defaults to a string.  But for the int_cpmg and int_ref, as
delayT is tested first and must be a number, for these unit tests you
must supply a random number to delayT.  I hope this clears up the
problem.

Regards,

Edward


On Tue, Jan 27, 2009 at 11:30 PM, Sébastien Morin
<sebastien.morin.1@xxxxxxxxx> wrote:

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




_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
relax-devel@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-devel






_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
relax-devel@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-devel




Related Messages


Powered by MHonArc, Updated Wed Jan 28 18:40:39 2009