mailr3157 - in /1.3: data/__init__.py generic_fns/pipes.py test_suite/unit_tests/generic_fns/test_pipes.py


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

Header


Content

Posted by edward on March 13, 2007 - 04:37:
Author: bugman
Date: Tue Mar 13 04:36:45 2007
New Revision: 3157

URL: http://svn.gna.org/viewcvs/relax?rev=3157&view=rev
Log:
Fixed the function generic_fns.pipes.create().

The relax data store singleton method 'add()' has been deleted as the method 
required the first
argument to be the singleton instance.  Instead the functionality has been 
shifted into the
generic_fns.pipes.create() function.  The unit tests have been modified for 
the new setup.

All references to 'run' in the file 
'test_suite/unit_tests/generic_fns/test_pipes.py' have been
replaced with 'pipe'.

Modified:
    1.3/data/__init__.py
    1.3/generic_fns/pipes.py
    1.3/test_suite/unit_tests/generic_fns/test_pipes.py

Modified: 1.3/data/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/__init__.py?rev=3157&r1=3156&r2=3157&view=diff
==============================================================================
--- 1.3/data/__init__.py (original)
+++ 1.3/data/__init__.py Tue Mar 13 04:36:45 2007
@@ -85,14 +85,14 @@
         text = text + "\n"
         text = text + "Objects:\n"
         for name in dir(self):
-            if match("^_", name) or name in DictType.__dict__ or name == 
'add':
+            if match("^_", name) or name in DictType.__dict__:
                 continue
             text = text + "  %s: %s\n" % (name, `getattr(self, name)`)
 
         # Methods.
         text = text + "\n"
         text = text + "Methods:\n"
-        text = text + "  add, Add a new pipe container to the dictionary.\n"
+        text = text + "  __reset__, Reset the relax data storage object back 
to its initial state\n"
 
         # DictType methods.
         text = text + "\n"
@@ -118,22 +118,3 @@
 
         # Remove all items from the dictionary.
         self.clear()
-
-
-    def add(self, pipe):
-        """Method for adding a new pipe container to the dictionary.
-
-        This method should be used rather than importing the PipeContainer 
class and using the
-        statement 'D[pipe] = PipeContainer()', where D is the relax data 
storage object and pipe is
-        the name of the data pipe.
-
-        @param pipe:    The name of the new data pipe.
-        @type pipe:     str
-        """
-
-        # Test if the pipe already exists.
-        if pipe in self.keys():
-            raise RelaxRunError, pipe
-
-        # Create a new container.
-        self[pipe] = PipeContainer()

Modified: 1.3/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pipes.py?rev=3157&r1=3156&r2=3157&view=diff
==============================================================================
--- 1.3/generic_fns/pipes.py (original)
+++ 1.3/generic_fns/pipes.py Tue Mar 13 04:36:45 2007
@@ -25,6 +25,7 @@
 
 # relax module imports.
 from data import Data
+from data.pipe_container import PipeContainer
 from relax_errors import RelaxError, RelaxNoRunError, RelaxRunError
 from specific_fns.relax_fit import C_module_exp_fn
 
@@ -37,7 +38,7 @@
 
 
 def create(pipe_name=None, pipe_type=None):
-    """Creating a new data pipe.
+    """Create a new data pipe.
 
     @param pipe_name:   The name of the new data pipe.
     @type pipe_name:    str
@@ -50,8 +51,8 @@
     @type pipe_type:    str
     """
 
-    # Test if the data pipe already exists.
-    if pipe_name in relax_data_store.pipe_names:
+    # Test if the pipe already exists.
+    if pipe_name in relax_data_store.keys():
         raise RelaxRunError, pipe_name
 
     # List of valid data pipe types.
@@ -65,9 +66,11 @@
     if pipe_type == 'relax_fit' and not C_module_exp_fn:
         raise RelaxError, "Relaxation curve fitting is not availible.  Try 
compiling the C modules on your platform."
 
-    # Add the data pipe name and type.
-    relax_data_store.pipe_names.append(pipe_name)
-    relax_data_store.pipe_types.append(pipe_type)
+    # Create a new container.
+    relax_data_store[pipe_name] = PipeContainer()
+
+    # Add the data pipe type string to the container.
+    relax_data_store[pipe_name].pipe_type = pipe_type
 
 
 def delete(pipe_name=None):

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=3157&r1=3156&r2=3157&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 Tue Mar 13 04:36:45 
2007
@@ -27,6 +27,7 @@
 
 # relax module imports.
 from data import Data
+from data.pipe_container import PipeContainer
 from generic_fns import pipes
 from relax_errors import RelaxError
 
@@ -41,8 +42,9 @@
     def setUp(self):
         """Set up for all the data pipe unit tests."""
 
-        # Add a run to the data store.
-        relax_data_store.add('orig')
+        # Add a data pipe to the data store.
+        relax_data_store['orig'] = PipeContainer()
+        relax_data_store['orig'].pipe_type = 'mf'
 
         # Add a single object to the 'orig' data pipe.
         relax_data_store['orig'].x = 1
@@ -51,7 +53,8 @@
         relax_data_store['orig'].mol[0].res[0].spin[0].num = 1
 
         # Add an empty data pipe (for the 'eliminate_unused_pipes' test).
-        relax_data_store.add('empty')
+        relax_data_store['empty'] = PipeContainer()
+        relax_data_store['empty'].pipe_type = 'mf'
 
 
     def test_creation(self):
@@ -67,8 +70,8 @@
         # Test that the data pipe exists.
         self.assert_(relax_data_store.has_key(name))
 
-        # Test that the current run is the new run.
-        self.assertEqual(relax_data_store.current_run, name)
+        # Test that the current pipe is the new pipe.
+        self.assertEqual(relax_data_store.current_pipe, name)
 
 
     def test_creation_fail(self):
@@ -87,9 +90,9 @@
         The function tested is generic_fns.pipes.delete()
         """
 
-        # Set the current run to the 'orig' data pipe.
+        # Set the current pipe to the 'orig' data pipe.
         name = 'orig'
-        relax_data_store.current_run = name
+        relax_data_store.current_pipe = name
 
         # Delete the 'orig' data pipe.
         pipes.delete(name)
@@ -97,8 +100,8 @@
         # Test that the data pipe no longer exists.
         self.assert_(not relax_data_store.has_key(name))
 
-        # Test that the current run is None (as the current run was deleted).
-        self.assertEqual(relax_data_store.current_run, None)
+        # Test that the current pipe is None (as the current pipe was 
deleted).
+        self.assertEqual(relax_data_store.current_pipe, None)
 
 
     def test_deletion_fail(self):
@@ -117,7 +120,7 @@
         The function tests is generic_fns.pipes.eliminate_unused_pipes().
         """
 
-        # The name of the empty run.
+        # The name of the empty pipe.
         name = 'empty'
 
         # Execute the cleanup function.
@@ -126,5 +129,5 @@
         # Test that the data pipe no longer exists.
         self.assert_(not relax_data_store.has_key(name))
 
-        # Test that the current run is None (as the current run was the 
empty run).
-        self.assertEqual(relax_data_store.current_run, None)
+        # Test that the current pipe is None (as the current pipe was the 
empty pipe).
+        self.assertEqual(relax_data_store.current_pipe, None)




Related Messages


Powered by MHonArc, Updated Tue Mar 13 04:40:05 2007