mailr2529 - in /branches/nan_catch_test: errors.py generic_fns/pdb.py minimise/line_search/backtrack.py specific_fns/model_free.py


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

Header


Content

Posted by edward on August 09, 2006 - 07:46:
Author: bugman
Date: Wed Aug  9 07:46:01 2006
New Revision: 2529

URL: http://svn.gna.org/viewcvs/relax?rev=2529&view=rev
Log:
Proposed changes to fix bug #6503 
(https://gna.org/bugs/?func=detailitem&item_id=6503) which has
been discussed within the thread starting at
https://mail.gna.org/public/relax-devel/2006-08/msg00000.html.


Modified:
    branches/nan_catch_test/errors.py
    branches/nan_catch_test/generic_fns/pdb.py
    branches/nan_catch_test/minimise/line_search/backtrack.py
    branches/nan_catch_test/specific_fns/model_free.py

Modified: branches/nan_catch_test/errors.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/nan_catch_test/errors.py?rev=2529&r1=2528&r2=2529&view=diff
==============================================================================
--- branches/nan_catch_test/errors.py (original)
+++ branches/nan_catch_test/errors.py Wed Aug  9 07:46:01 2006
@@ -462,3 +462,17 @@
     class RelaxInvalidColourError(BaseError):
         def __init__(self, colour):
             self.text = "The colour " + `colour` + " is invalid."
+
+
+    # Value errors.
+    ###############
+
+    # Infinity.
+    class RelaxInfError(BaseError):
+        def __init__(self, name):
+            self.text = "The invalid " + name + " floating point value of 
infinity has occurred."
+
+    # NaN (Not a Number).
+    class RelaxNaNError(BaseError):
+        def __init__(self, name):
+            self.text = "The invalid " + name + " floating point value of 
NaN (Not a Number) has occurred."

Modified: branches/nan_catch_test/generic_fns/pdb.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/nan_catch_test/generic_fns/pdb.py?rev=2529&r1=2528&r2=2529&view=diff
==============================================================================
--- branches/nan_catch_test/generic_fns/pdb.py (original)
+++ branches/nan_catch_test/generic_fns/pdb.py Wed Aug  9 07:46:01 2006
@@ -156,6 +156,10 @@
                     print "The PDB file " + `self.file_path` + " cannot be 
found, no structures will be loaded."
                 return
 
+        # Test that the nuclei have been correctly set.
+        if self.heteronuc == self.proton:
+            raise RelaxError, "The proton and heteronucleus are set to the 
same atom."
+
 
         # Data creation.
         ################
@@ -256,9 +260,18 @@
                     # Get the heteronucleus position.
                     posX = pdb_res.atoms[self.heteronuc].position.array
 
+                    # Calculate the XH bond vector.
+                    vector = posH - posX
+
+                    # Normalisation factor.
+                    norm_factor = sqrt(dot(vector, vector))
+
+                    # Test for zero length.
+                    if norm_factor == 0.0:
+                        raise RelaxError, "The XH bond vector for residue " 
+ `self.relax.data.res[self.run][j].num` + " is of zero length."
+
                     # Calculate the normalised vector.
-                    vector = posH - posX
-                    self.relax.data.res[self.run][j].xh_vect.append(vector / 
sqrt(dot(vector, vector)))
+                    self.relax.data.res[self.run][j].xh_vect.append(vector / 
norm_factor)
 
         # Print out.
         if self.print_flag:

Modified: branches/nan_catch_test/minimise/line_search/backtrack.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/nan_catch_test/minimise/line_search/backtrack.py?rev=2529&r1=2528&r2=2529&view=diff
==============================================================================
--- branches/nan_catch_test/minimise/line_search/backtrack.py (original)
+++ branches/nan_catch_test/minimise/line_search/backtrack.py Wed Aug  9 
07:46:01 2006
@@ -23,7 +23,7 @@
 
 from Numeric import dot
 
-def backtrack(func, args, x, f, g, p, a_init=1.0, rho=0.5, c=1e-4):
+def backtrack(func, args, x, f, g, p, a_init=1.0, rho=0.5, c=1e-4, 
max_iter=500):
     """Backtracking line search.
 
     Procedure 3.1, page 41, from 'Numerical Optimization' by Jorge Nocedal 
and Stephen J. Wright,
@@ -63,8 +63,9 @@
     # Initialise values.
     a = a_init
     f_count = 0
+    i = 0
 
-    while 1:
+    while i <= max_iter:
         fk = apply(func, (x + a*p,)+args)
         f_count = f_count + 1
 
@@ -73,3 +74,6 @@
             return a, f_count
         else:
             a = rho*a
+
+        # Increment the counter.
+        i = i + 1

Modified: branches/nan_catch_test/specific_fns/model_free.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/nan_catch_test/specific_fns/model_free.py?rev=2529&r1=2528&r2=2529&view=diff
==============================================================================
--- branches/nan_catch_test/specific_fns/model_free.py (original)
+++ branches/nan_catch_test/specific_fns/model_free.py Wed Aug  9 07:46:01 
2006
@@ -2373,6 +2373,14 @@
             self.f_count = self.f_count + fc
             self.g_count = self.g_count + gc
             self.h_count = self.h_count + hc
+
+            # Catch infinite chi-squared values.
+            if self.func == float('inf'):
+                raise RelaxInfError
+
+            # Catch chi-squared values of NaN.
+            if isnan(self.func):
+                raise RelaxNaNError
 
             # Scaling.
             if scaling:




Related Messages


Powered by MHonArc, Updated Wed Aug 09 08:00:09 2006