Hi Ed. Thanks for your comments.
I thought about my own comments, and think they are rubbish. :-) Best Troels 2014-05-19 13:56 GMT+02:00 Edward d'Auvergne <[email protected]>: > Hi, > > I don't quite understand the 'turning-off' part. Why do you need > this? When would you like to turn it on, and when would you like to > turn it off? You can use --numpy-raise while debugging, but then not > use it for for normal use of relax. I don't see a need to turn this > off when performing a debugging run with --numpy-raise, as that is > only a temporary run for testing. > > Regards, > > Edward > > > > On 19 May 2014 13:05, Troels Emtekær Linnet <[email protected]> wrote: >> Hi Ed. >> >> I have been playing with this. >> >> I really like the --numpy-raise option. >> >> But then I need to also turn this off when I know I have handled the >> exception. >> >> I have been looking at: >> numpy.seterr >> http://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html#numpy-seterr >> >> Putting this is in: >> import numpy as np >> old_settings = np.seterr() >> old_settings2 = np.geterr() >> >> print "old settings" >> print old_settings >> np.seterr(all='ignore') >> print "new settings" >> print np.seterr() >> >> print "bla bla bla code with math domain errors, but handled." >> >> # Go back to original >> np.seterr(over=old_settings['over']) >> np.seterr(divide=old_settings['divide']) >> np.seterr(invalid=old_settings['invalid']) >> np.seterr(under=old_settings['under']) >> >> print "back to normal" >> print np.seterr() >> >> 2014-05-19 10:02 GMT+02:00 Edward d'Auvergne <[email protected]>: >>> Hi Troels, >>> >>> When making such important changes, for debugging you should try >>> running the test suite as: >>> >>> $ ./relax -s Relax_disp --numpy-raise >>> Echoing of user function calls has been enabled. >>> >>> >>> ============================= >>> = System / functional tests = >>> ============================= >>> >>> EE.EEEEEEEE...EE.EEEEEEEEEEEEE.EEEEEEEEEEEEEEEEEEE...EEEEEEEEEEE... >>> ====================================================================== >>> >>> This will quickly uncover the places where we need to have checks in >>> the code. It will also uncover many places in the trunk does not have >>> checks, so don't worry about the huge number of errors. This is the >>> code from all of the contributors on the paper: >>> >>> - Morin, S., Linnet, T. E., Lescanne, M., Schanda, P., Thompson, >>> G. S., Tollinger, M., Teilum, K., Gagné, S., Marion, D., Griesinger, >>> C., Blackledge, M., and d'Auvergne, E. J. (2014). relax: the analysis >>> of biomolecular kinetics and thermodynamics using NMR relaxation >>> dispersion data. Bioinformatics. >>> (http://dx.doi.org/10.1093/bioinformatics/btu166). >>> >>> And as it comes from many groups, the error checking is not consistent >>> or perfected yet. >>> >>> Regards, >>> >>> Edward >>> >>> >>> >>> >>> >>> On 18 May 2014 23:36, <[email protected]> wrote: >>>> Author: tlinnet >>>> Date: Sun May 18 23:36:14 2014 >>>> New Revision: 23216 >>>> >>>> URL: http://svn.gna.org/viewcvs/relax?rev=23216&view=rev >>>> Log: >>>> Huge speed-up for model CR72. >>>> >>>> task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models. >>>> >>>> Systemtest Relax_disp.test_cpmg_synthetic_cr72_full_noise_cluster >>>> changes from 7 seconds to 4.5 seconds. >>>> >>>> This is won by not checking single values in the R2eff array for math >>>> domain >>>> errors, but calculating all steps, and in one single round check for >>>> finite values. >>>> If just one non-finite value is found, the whole array is returned with a >>>> large >>>> penalty of 1e100. >>>> >>>> This makes all calculations be the fastest numpy array way. >>>> >>>> Modified: >>>> branches/disp_speed/lib/dispersion/cr72.py >>>> >>>> Modified: branches/disp_speed/lib/dispersion/cr72.py >>>> URL: >>>> http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/cr72.py?rev=23216&r1=23215&r2=23216&view=diff >>>> ============================================================================== >>>> --- branches/disp_speed/lib/dispersion/cr72.py (original) >>>> +++ branches/disp_speed/lib/dispersion/cr72.py Sun May 18 23:36:14 2014 >>>> @@ -92,8 +92,10 @@ >>>> """ >>>> >>>> # Python module imports. >>>> -from numpy import arccosh, cos, cosh, sqrt >>>> +from numpy import arccosh, array, cos, cosh, isfinite, sqrt, sum >>>> >>>> +# Repetitive calculations (to speed up calculations). >>>> +eta_scale = 2.0**(-3.0/2.0) >>>> >>>> def r2eff_CR72(r20a=None, r20b=None, pA=None, dw=None, kex=None, >>>> cpmg_frqs=None, back_calc=None, num_points=None): >>>> """Calculate the R2eff values for the CR72 model. >>>> @@ -146,26 +148,17 @@ >>>> Dneg = 0.5 * (-1.0 + D_part) >>>> >>>> # Partial eta+/- values. >>>> - eta_scale = 2.0**(-3.0/2.0) >>>> - etapos_part = eta_scale * sqrt(Psi + sqrt_psi2_zeta2) >>>> - etaneg_part = eta_scale * sqrt(-Psi + sqrt_psi2_zeta2) >>>> + etapos = eta_scale * sqrt(Psi + sqrt_psi2_zeta2) / cpmg_frqs >>>> + etaneg = eta_scale * sqrt(-Psi + sqrt_psi2_zeta2) / cpmg_frqs >>>> >>>> - # Loop over the time points, back calculating the R2eff values. >>>> + # Calculate R2eff. >>>> + R2eff = r20_kex - cpmg_frqs * arccosh( Dpos * cosh(etapos) - Dneg * >>>> cos(etaneg) ) >>>> + >>>> + # Catch errors, taking a sum over array is the fastest way to check >>>> for >>>> + # +/- inf (infinity) and nan (not a number). >>>> + if not isfinite(sum(R2eff)): >>>> + R2eff = array([1e100]*num_points) >>>> + >>>> + # Parse back the value to update the back_calc class object. >>>> for i in range(num_points): >>>> - # The full eta+/- values. >>>> - etapos = etapos_part / cpmg_frqs[i] >>>> - etaneg = etaneg_part / cpmg_frqs[i] >>>> - >>>> - # Catch large values of etapos going into the cosh function. >>>> - if etapos > 100: >>>> - back_calc[i] = 1e100 >>>> - continue >>>> - >>>> - # The arccosh argument - catch invalid values. >>>> - fact = Dpos * cosh(etapos) - Dneg * cos(etaneg) >>>> - if fact < 1.0: >>>> - back_calc[i] = r20_kex >>>> - continue >>>> - >>>> - # The full formula. >>>> - back_calc[i] = r20_kex - cpmg_frqs[i] * arccosh(fact) >>>> + back_calc[i] = R2eff[i] >>>> >>>> >>>> _______________________________________________ >>>> relax (http://www.nmr-relax.com) >>>> >>>> This is the relax-commits mailing list >>>> [email protected] >>>> >>>> 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://www.nmr-relax.com) >>> >>> This is the relax-devel mailing list >>> [email protected] >>> >>> 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://www.nmr-relax.com) This is the relax-devel mailing list [email protected] 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

