mailRe: r22283 - /trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py


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

Header


Content

Posted by Edward d'Auvergne on February 24, 2014 - 14:55:
Hi,

Unfortunately it will be a little more complicated.  The
cdp.relax_times data structure is simply a dictionary, so
cdp.relax_times[id] will be a single floating point number.  All of
the relaxation dispersion metadata in the base data pipe object are
simple dictionaries of floats, ints, etc.  The complication is due to
how the time index is used!  If you run:

$ grep "loop_.*time(" -r . --exclude-dir=.svn

And then look at all the places the looping over times is used, you
will see that the time index is currently unused!  But the key is in
the target_functions.relax_disp module, specifically the relax_times
argument which has the description:

        @keyword relax_times:       The experiment specific fixed time
period for relaxation (in seconds).  The dimensions are {Ei, Mi}.
        @type relax_times:          rank-2 list of floats

So it is currently experiment and magnetic field specific.  This is
likely to be expanded in the future to be offset and even dispersion
point specific, well after a user complains about relax not supporting
this.

In the case of your data, you only have one time for each magnetic
field strength, so the index is always 0.  You should test against
this value as the logic of the loop_*() methods should return this.
These tests should be added despite the ti index not being used, as
that will avoid problems in the future!

Cheers,

Edward




On 24 February 2014 14:31, Troels Emtekær Linnet <tlinnet@xxxxxxxxxxxxx> 
wrote:
Hi Edward.

The unit test "test_loop_exp_frq_offset_point_time" is now setup fail.

This is because I am unsure which function the time index have.

Is the function of the time index to extract the time point from the
spectrum id: cdp.relax_times[id] [time_index]
or from cdp.relax_time_list ?

If it is the cdp.relax_times[id] [time_index], then I can safely
change the unit test to pass.

Best
Troels


---------- Forwarded message ----------
From:  <tlinnet@xxxxxxxxxxxxx>
Date: 2014-02-24 14:20 GMT+01:00
Subject: r22283 -
/trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
To: relax-commits@xxxxxxx


Author: tlinnet
Date: Mon Feb 24 14:20:41 2014
New Revision: 22283

URL: http://svn.gna.org/viewcvs/relax?rev=22283&view=rev
Log:
Added unit test for looping over: exp, frq, offset, point, time.

Regarding bug #21665, (https://gna.org/bugs/?21665) - Running a CPMG
analysis with two fields at two delay times.

This unit test will fail, since the last loop over the time points has
a weak assumption just to loop over all time points,
instead of checking for existence of such time point.
This unit test follows recommendation in thread:
http://thread.gmane.org/gmane.science.nmr.relax.devel/5070.

Modified:
    
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py

Modified: 
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py?rev=22283&r1=22282&r2=22283&view=diff
==============================================================================
--- 
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
(original)
+++ 
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
Mon Feb 24 14:20:41 2014
@@ -186,6 +186,69 @@
             # Check the dispersion point info.
             self.assertAlmostEqual(point, data[frq_index][3][disp_index],2)
             self.assertEqual(di, indices[frq_index][3][disp_index])
+
+            # Increment the data index.
+            if disp_index == 16:
+                frq_index += 1
+                disp_index = 0
+            else:
+                disp_index += 1
+
+
+    def test_loop_exp_frq_offset_point_time(self):
+        """Unit test of the loop_exp_frq_offset_point_time() function.
+
+        This uses the data of the saved state attached to U{bug
#21665<https://gna.org/bugs/?21665>}.
+        """
+
+        # Load the state.
+        statefile = status.install_path +
sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
+        state.load_state(statefile, force=True)
+
+        # Original data (exp_type, frq, offset, point).
+        data = [
+            ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0,
250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0,
800.0, 900.0, 1000.0],0.04],
+            ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666,
100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333,
366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0],0.06]
+        ]
+
+        # Original indices (ei, mi, oi).
+        indices = [
+            [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16], 0],
+            [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16], 1]
+        ]
+
+        # Check the number of iterations.
+        print("Checking the number of iterations of the loop.")
+        count = 0
+        for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in
loop_exp_frq_offset_point_time(return_indices=True):
+            print exp_type, frq, offset, point, time, ei, mi, oi, di, ti
+            count += 1
+        self.assertEqual(count, 34)
+
+        # Check the values.
+        print("Checking the values returned by the loop.")
+        frq_index = 0
+        disp_index = 0
+        for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in
loop_exp_frq_offset_point_time(return_indices=True):
+            # Check the experiment info.
+            self.assertEqual(exp_type, data[frq_index][0])
+            self.assertEqual(ei, indices[frq_index][0])
+
+            # Check the frequency info.
+            self.assertEqual(frq, data[frq_index][1])
+            self.assertEqual(mi, indices[frq_index][1])
+
+            # Check the offset info.
+            self.assertEqual(offset, data[frq_index][2])
+            self.assertEqual(oi, indices[frq_index][2])
+
+            # Check the dispersion point info.
+            self.assertAlmostEqual(point, data[frq_index][3][disp_index],2)
+            self.assertEqual(di, indices[frq_index][3][disp_index])
+
+            # Check the time point info.
+            self.assertEqual(time, data[frq_index][4])
+            self.assertEqual(ti, indices[frq_index][4])

             # Increment the data index.
             if disp_index == 16:


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

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
relax-devel@xxxxxxx

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



Related Messages


Powered by MHonArc, Updated Mon Feb 24 15:00:10 2014