Right, I forgot about the array type of theta! Don't worry about that part then, there are no bugs :)
Regards, Edward On 22 May 2014 16:58, Troels Emtekær Linnet <[email protected]> wrote: > Hi Ed. > > In DPL94, R1_R2 value will be a numpy array that match the R2eff dimensions. > > R1_R2 = R1 * cos(theta)**2 + r1rho_prime * sin_theta2 > > and theta is an array. > > Best > Troels > > 2014-05-21 15:05 GMT+02:00 Edward d'Auvergne <[email protected]>: >> Hi Troels, >> >> This change looks like it has introduced a bug. The R1_R2 value will >> not be a numpy array matching the R2eff dimensions. >> >> I have a suggestion to catch these types of problem. It's very simple >> to implement too. Just add unit tests for all of the lib.dispersion >> modules! Simply create new modules in >> test_suite/unit_tests/_lib/_dispersion/ called test_b14.py, etc., >> import the r2eff_*() or r1rho_*() function for each, send in a set of >> parameter values, and test that all the returned R2eff values match >> the average of R20A and R20B (or R1rho matches the R1 + R1rho' >> combination). Thanks to the clean API separation of lib.dispersion, >> this would be only a few lines of code to check each module. >> Something like this pseudo-code: >> >> def test_b14(self): >> """Fill me in...""" >> >> R2eff = r2eff_b14(r20a=1.0, r20b=2.0, pA=1.0, pB=0.0, dw=1.0, kex=100.0, >> ... >> for i in range(len(R2eff)): >> self.assertEqual(R2eff[i], 1.5) >> >> You could set up 3 different unit tests for each, one where dw = 0.0, >> the next pA = 1.0, and the last with kex = 0.0. Or phi_ex =0.0, etc. >> This will force the dispersion code to return perfect R2eff values at >> all edge cases. You could even copy the tests and modify them to test >> the infinite values as well. These tests will be incredibly quick to >> run. >> >> Regards, >> >> Edward >> >> >> P. S. Oh, for the test in this module, you might find the code faster >> if you replace "if min(numer) == 0.0:" with "if phi_ex == 0.0 or kex >> == 0.0". That would avoid operating on numpy arrays. >> >> On 21 May 2014 13:02, <[email protected]> wrote: >>> Author: tlinnet >>> Date: Wed May 21 13:02:56 2014 >>> New Revision: 23296 >>> >>> URL: http://svn.gna.org/viewcvs/relax?rev=23296&view=rev >>> Log: >>> Align math-domain catching for model DPL94 with trunk implementation. >>> >>> task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models. >>> >>> This is to implement catching of math domain errors, before they occur. >>> >>> The catching of errors have to be more careful. >>> >>> Modified: >>> branches/disp_speed/lib/dispersion/dpl94.py >>> >>> Modified: branches/disp_speed/lib/dispersion/dpl94.py >>> URL: >>> http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/dpl94.py?rev=23296&r1=23295&r2=23296&view=diff >>> ============================================================================== >>> --- branches/disp_speed/lib/dispersion/dpl94.py (original) >>> +++ branches/disp_speed/lib/dispersion/dpl94.py Wed May 21 13:02:56 2014 >>> @@ -98,6 +98,11 @@ >>> # The numerator. >>> numer = sin_theta2 * phi_ex * kex >>> >>> + # Catch zeros (to avoid pointless mathematical operations). >>> + # This will result in no exchange, returning flat lines. >>> + if min(numer) == 0.0: >>> + return R1_R2 >>> + >>> # Denominator. >>> denom = kex2 + spin_lock_fields2 >>> >>> >>> >>> _______________________________________________ >>> 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

