mailr3197 - 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 15, 2007 - 05:58:
Author: bugman
Date: Thu Mar 15 05:57:50 2007
New Revision: 3197

URL: http://svn.gna.org/viewcvs/relax?rev=3197&view=rev
Log:
Manually reverted most of r3157.

The 'add()' method of the relax data storage singleton has been reintroduced.


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=3197&r1=3196&r2=3197&view=diff
==============================================================================
--- 1.3/data/__init__.py (original)
+++ 1.3/data/__init__.py Thu Mar 15 05:57:50 2007
@@ -84,7 +84,7 @@
         text = text + "\n"
         text = text + "Objects:\n"
         for name in dir(self):
-            if match("^_", name) or name in dict.__dict__:
+            if match("^_", name) or name in dict.__dict__ or name == 'add':
                 continue
             text = text + "  %s: %s\n" % (name, `getattr(self, name)`)
 
@@ -92,6 +92,8 @@
         text = text + "\n"
         text = text + "Methods:\n"
         text = text + "  __reset__, Reset the relax data storage object back 
to its initial state\n"
+        text = text + "  add, Add a new data pipe container.\n"
+
 
         # dict methods.
         text = text + "\n"
@@ -117,3 +119,29 @@
 
         # Remove all items from the dictionary.
         self.clear()
+
+
+    def add(self, pipe_name, pipe_type):
+        """Method for adding a new data 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_name in self.keys():
+            raise RelaxRunError, pipe_name
+
+        # Create a new container.
+        self[pipe_name] = PipeContainer()
+
+        # Add the data pipe type string to the container.
+        self[pipe_name].pipe_type = pipe_type
+
+        # Change the current data pipe.
+        self.current_pipe = pipe_name
+

Modified: 1.3/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pipes.py?rev=3197&r1=3196&r2=3197&view=diff
==============================================================================
--- 1.3/generic_fns/pipes.py (original)
+++ 1.3/generic_fns/pipes.py Thu Mar 15 05:57:50 2007
@@ -22,7 +22,6 @@
 
 # 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
 
@@ -75,10 +74,6 @@
     @type pipe_type:    str
     """
 
-    # Test if the pipe already exists.
-    if pipe_name in relax_data_store.keys():
-        raise RelaxRunError, pipe_name
-
     # List of valid data pipe types.
     valid = ['jw', 'mf', 'noe', 'relax_fit', 'srls']
 
@@ -90,14 +85,8 @@
     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."
 
-    # 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
-
-    # Change the current data pipe.
-    relax_data_store.current_pipe = pipe_name
+    # Add the data pipe.
+    relax_data_store.add(pipe_name=pipe_name, pipe_type=pipe_type)
 
 
 def current():

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=3197&r1=3196&r2=3197&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 Thu Mar 15 05:57:50 
2007
@@ -41,8 +41,7 @@
         """Set up for all the data pipe unit tests."""
 
         # Add a data pipe to the data store.
-        relax_data_store['orig'] = PipeContainer()
-        relax_data_store['orig'].pipe_type = 'mf'
+        relax_data_store.add(pipe_name='orig', pipe_type='mf')
 
         # Add a single object to the 'orig' data pipe.
         relax_data_store['orig'].x = 1
@@ -51,8 +50,7 @@
         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['empty'] = PipeContainer()
-        relax_data_store['empty'].pipe_type = 'mf'
+        relax_data_store.add(pipe_name='empty', pipe_type='mf')
 
         # Set the current run to the 'orig' data pipe.
         relax_data_store.current_pipe = 'orig'




Related Messages


Powered by MHonArc, Updated Thu Mar 15 11:00:09 2007