mailr3219 - in /1.3/test_suite/unit_tests/generic_fns: test_pipes.py test_selection.py


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

Header


Content

Posted by edward on March 19, 2007 - 06:00:
Author: bugman
Date: Mon Mar 19 05:59:48 2007
New Revision: 3219

URL: http://svn.gna.org/viewcvs/relax?rev=3219&view=rev
Log:
Wrote a unit test for the generic_fns.selection.reverse() function.

Added:
    1.3/test_suite/unit_tests/generic_fns/test_selection.py
Modified:
    1.3/test_suite/unit_tests/generic_fns/test_pipes.py

Modified: 1.3/test_suite/unit_tests/generic_fns/test_pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/generic_fns/test_pipes.py?rev=3219&r1=3218&r2=3219&view=diff
==============================================================================
--- 1.3/test_suite/unit_tests/generic_fns/test_pipes.py (original)
+++ 1.3/test_suite/unit_tests/generic_fns/test_pipes.py Mon Mar 19 05:59:48 
2007
@@ -52,7 +52,7 @@
         # Add an empty data pipe (for the 'eliminate_unused_pipes' test).
         relax_data_store.add(pipe_name='empty', pipe_type='mf')
 
-        # Set the current run to the 'orig' data pipe.
+        # Set the current pipe to the 'orig' data pipe.
         relax_data_store.current_pipe = 'orig'
 
 

Added: 1.3/test_suite/unit_tests/generic_fns/test_selection.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/generic_fns/test_selection.py?rev=3219&view=auto
==============================================================================
--- 1.3/test_suite/unit_tests/generic_fns/test_selection.py (added)
+++ 1.3/test_suite/unit_tests/generic_fns/test_selection.py Mon Mar 19 
05:59:48 2007
@@ -1,0 +1,92 @@
+###############################################################################
+#                                                                            
 #
+# Copyright (C) 2007 Edward d'Auvergne                                       
 #
+#                                                                            
 #
+# This file is part of the program relax.                                    
 #
+#                                                                            
 #
+# relax is free software; you can redistribute it and/or modify              
 #
+# it under the terms of the GNU General Public License as published by       
 #
+# the Free Software Foundation; either version 2 of the License, or          
 #
+# (at your option) any later version.                                        
 #
+#                                                                            
 #
+# relax is distributed in the hope that it will be useful,                   
 #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
+# GNU General Public License for more details.                               
 #
+#                                                                            
 #
+# You should have received a copy of the GNU General Public License          
 #
+# along with relax; if not, write to the Free Software                       
 #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
 #
+#                                                                            
 #
+###############################################################################
+
+# Python module imports.
+from unittest import TestCase
+
+# relax module imports.
+from data import Data as relax_data_store
+from generic_fns import selection
+
+
+class Test_selection(TestCase):
+    """Unit tests for the functions of the 'generic_fns.selection' module."""
+
+    def setUp(self):
+        """Set up some residues and spins for testing their selection and 
deselection."""
+
+        # Add a data pipe to the data store.
+        relax_data_store.add(pipe_name='orig', pipe_type='mf')
+
+        # Alias the current data pipe.
+        cdp = relax_data_store[relax_data_store.current_pipe]
+
+        # Add a second molecule to the system.
+        cdp.mol.add_item()
+
+        # Add two more residues to the first molecule (and set the residue 
number of the first).
+        cdp.mol[0].res[0].num = 1
+        cdp.mol[0].res.add_item(res_num=2)
+        cdp.mol[0].res.add_item(res_num=4)
+
+        # Add one more residue to the second molecule (and set the residue 
number of the first).
+        cdp.mol[1].res[0].num = -5
+        cdp.mol[1].res.add_item(res_num=-4)
+
+        # Add a second set of spins to the second molecule.
+        cdp.mol[1].res[0].spin.add_item(spin_name='N5')
+        cdp.mol[1].res[1].spin.add_item(spin_name='N5')
+
+        # Deselect a number of spins.
+        cdp.mol[0].res[0].spin[0].select = 0
+        cdp.mol[0].res[2].spin[0].select = 0
+        cdp.mol[1].res[0].spin[0].select = 0
+        cdp.mol[1].res[1].spin[1].select = 0
+
+
+    def tearDown(self):
+        """Reset the relax data storage object."""
+
+        # Reset.
+        relax_data_store.__reset__()
+
+        
+    def test_reverse(self):
+        """Test spin system selection reversal.
+
+        The function tested is generic_fns.selection.reverse().
+        """
+
+        # Reverse the selection.
+        selection.reverse()
+
+        # Alias the current data pipe.
+        cdp = relax_data_store[relax_data_store.current_pipe]
+
+        # Test the selection status.
+        self.assertEqual(cdp.mol[0].res[0].spin[0].select, 1)
+        self.assertEqual(cdp.mol[0].res[1].spin[0].select, 0)
+        self.assertEqual(cdp.mol[0].res[2].spin[0].select, 1)
+        self.assertEqual(cdp.mol[1].res[0].spin[0].select, 1)
+        self.assertEqual(cdp.mol[1].res[0].spin[1].select, 0)
+        self.assertEqual(cdp.mol[1].res[1].spin[0].select, 0)
+        self.assertEqual(cdp.mol[1].res[1].spin[1].select, 1)




Related Messages


Powered by MHonArc, Updated Mon Mar 19 06:20:06 2007