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: _______________________________________________ relax (http://nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org 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