mailr2553 - in /1.2: errors.py float.py generic_fns/pdb.py minimise/line_search/backtrack.py relax 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 September 03, 2006 - 10:29:
Author: bugman
Date: Sun Sep  3 10:28:49 2006
New Revision: 2553

URL: http://svn.gna.org/viewcvs/relax?rev=2553&view=rev
Log:
Merged the 'nan_catch_test' branch (r2552) into the 1.2 line (r2552).

The command used was:
svn merge svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.2@2552 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/nan_catch_test@2552

This branch was created as a branch off the 1.2 line at r2528.  It was in 
response to bug #6503
(https://gna.org/bugs/?func=detailitem&item_id=6503) and the subsequent 
discussions in the threads
starting at https://mail.gna.org/public/relax-devel/2006-08/msg00000.html
(Message-id: <7f080ed10608020558o47fd0260s9579f663147ab84@xxxxxxxxxxxxxx>) and
https://mail.gna.org/public/relax-devel/2006-08/msg00029.html (Message-id:
<7f080ed10608082240r114cf35an60af62836fcc81bf@xxxxxxxxxxxxxx>).

The two functions 'isnan()' and 'isinf()' have been created to fix the bug.  
These are however not
currently functional.  In addition bug #6510 
(https://gna.org/bugs/?func=detailitem&item_id=6510)
has been fixed.


Added:
    1.2/float.py
      - copied unchanged from r2552, branches/nan_catch_test/float.py
Modified:
    1.2/errors.py
    1.2/generic_fns/pdb.py
    1.2/minimise/line_search/backtrack.py
    1.2/relax
    1.2/specific_fns/model_free.py

Modified: 1.2/errors.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/errors.py?rev=2553&r1=2552&r2=2553&view=diff
==============================================================================
--- 1.2/errors.py (original)
+++ 1.2/errors.py Sun Sep  3 10:28:49 2006
@@ -597,4 +597,21 @@
             self.text = "The colour " + `colour` + " is invalid."
             if Debug:
                 self.save_state()
-                                            
+
+
+    # Value errors.
+    ###############
+
+    # Infinity.
+    class RelaxInfError(BaseError):
+        def __init__(self, name):
+            self.text = "The invalid " + name + " floating point value of 
infinity has occurred."
+            if Debug:
+                self.save_state()
+
+    # 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."
+            if Debug:
+                self.save_state()

Modified: 1.2/generic_fns/pdb.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/generic_fns/pdb.py?rev=2553&r1=2552&r2=2553&view=diff
==============================================================================
--- 1.2/generic_fns/pdb.py (original)
+++ 1.2/generic_fns/pdb.py Sun Sep  3 10:28:49 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,21 @@
                     # 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:
+                        if self.print_flag:
+                            print "The XH bond vector for residue " + 
`self.relax.data.res[self.run][j].num` + " is of zero length."
+                        self.relax.data.res[self.run][j].xh_vect.append(None)
+
                     # Calculate the normalised vector.
-                    vector = posH - posX
-                    self.relax.data.res[self.run][j].xh_vect.append(vector / 
sqrt(dot(vector, vector)))
+                    else:
+                        
self.relax.data.res[self.run][j].xh_vect.append(vector / norm_factor)
 
         # Print out.
         if self.print_flag:

Modified: 1.2/minimise/line_search/backtrack.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/minimise/line_search/backtrack.py?rev=2553&r1=2552&r2=2553&view=diff
==============================================================================
--- 1.2/minimise/line_search/backtrack.py (original)
+++ 1.2/minimise/line_search/backtrack.py Sun Sep  3 10:28:49 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: 1.2/relax
URL: 
http://svn.gna.org/viewcvs/relax/1.2/relax?rev=2553&r1=2552&r2=2553&view=diff
==============================================================================
--- 1.2/relax (original)
+++ 1.2/relax Sun Sep  3 10:28:49 2006
@@ -67,6 +67,7 @@
 from colour import Colour
 from data import Data
 from errors import RelaxErrors
+from float import Float
 from io import IO
 from generic_fns.main import Generic
 from prompt.gpl import gpl
@@ -110,6 +111,9 @@
         # File operation functions.
         self.IO = IO(self)
 
+        # Floating point number functions.
+        self.float = Float()
+
         # Colour operations.
         self.colour = Colour()
 

Modified: 1.2/specific_fns/model_free.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/specific_fns/model_free.py?rev=2553&r1=2552&r2=2553&view=diff
==============================================================================
--- 1.2/specific_fns/model_free.py (original)
+++ 1.2/specific_fns/model_free.py Sun Sep  3 10:28:49 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.relax.float.isinf(self.func):
+            #    raise RelaxInfError, 'chi-squared'
+
+            # Catch chi-squared values of NaN.
+            #if self.relax.float.isnan(self.func):
+            #    raise RelaxNaNError, 'chi-squared'
 
             # Scaling.
             if scaling:




Related Messages


Powered by MHonArc, Updated Mon Sep 04 09:40:04 2006