mailr4084 - /1.3/specific_fns/relax_data.py


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

Header


Content

Posted by edward on November 28, 2007 - 09:17:
Author: bugman
Date: Wed Nov 28 09:17:13 2007
New Revision: 4084

URL: http://svn.gna.org/viewcvs/relax?rev=4084&view=rev
Log:
Rewrote the specific_fns.relax_data.data_init() function.

This was a big simplification!


Modified:
    1.3/specific_fns/relax_data.py

Modified: 1.3/specific_fns/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/specific_fns/relax_data.py?rev=4084&r1=4083&r2=4084&view=diff
==============================================================================
--- 1.3/specific_fns/relax_data.py (original)
+++ 1.3/specific_fns/relax_data.py Wed Nov 28 09:17:13 2007
@@ -299,61 +299,35 @@
                 self.update_data_structures(data2, value, error)
 
 
-    def data_init(self, data):
-        """Function for initialising the data structures."""
+    def data_init(self, container):
+        """Function for initialising the data structures for a spin 
container.
+
+        @param container:   The data pipe or spin data container 
(PipeContainer or SpinContainer).
+        @type container:    class instance
+        """
 
         # Get the data names.
         data_names = self.data_names()
 
+        # Init.
+        list_data = [ 'relax_data',
+                      'relax_error',
+                      'ri_labels',
+                      'remap_table',
+                      'noe_r1_table',
+                      'frq_labels',
+                      'frq' ]
+        zero_data = [ 'num_ri', 'num_frq' ]
+
         # Loop over the data structure names.
         for name in data_names:
-            # Global data.
-            if self.global_flag == 1:
-                # Add the global data structure if it does not exist.
-                if not hasattr(data, name):
-                    setattr(data, name, {})
-
-            # Data structures which are initially empty arrays.
-            list_data = [ 'relax_data',
-                          'relax_error',
-                          'ri_labels',
-                          'remap_table',
-                          'noe_r1_table',
-                          'frq_labels',
-                          'frq' ]
-            if name in list_data:
-                # Global data.
-                if self.global_flag == 1:
-                    # Get the object.
-                    object = getattr(data, name)
-
-                    # Add the data if the key is missing.
-                    if not object.has_key(self.run):
-                        object[self.run] = []
-
-                # Residue specific data.
-                else:
-                    # If the name is not in 'data', add it.
-                    if not hasattr(data, name):
-                        setattr(data, name, [])
-
-            # Data structures which are initially zero.
-            zero_data = [ 'num_ri', 'num_frq' ]
-            if name in zero_data:
-                # Global data.
-                if self.global_flag == 1:
-                    # Get the object.
-                    object = getattr(data, name)
-
-                    # Add the data if the key is missing.
-                    if not object.has_key(self.run):
-                        object[self.run] = 0
-
-                # Residue specific data.
-                else:
-                    # If the name is not in 'data', add it.
-                    if not hasattr(data, name):
-                        setattr(data, name, 0)
+            # If the name is not in the container, add it as an empty array.
+            if name in list_data and not hasattr(container, name):
+                setattr(container, name, [])
+
+            # If the name is not in the container, add it as a variable set 
to zero.
+            if name in zero_data and not hasattr(container, name):
+                setattr(container, name, 0)
 
 
     def data_names(self):




Related Messages


Powered by MHonArc, Updated Wed Nov 28 09:40:06 2007