mailr5445 - in /1.3: data/mol_res_spin.py generic_fns/spin.py


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

Header


Content

Posted by edward on April 08, 2008 - 17:56:
Author: bugman
Date: Tue Apr  8 17:41:04 2008
New Revision: 5445

URL: http://svn.gna.org/viewcvs/relax?rev=5445&view=rev
Log:
Code shift, similar to that of r5443.

Shifted the spin number check (cannot have 2 spin with the same number) and 
1st element replacement
(if that SpinContainer is empty) code from generic_fns.spin.create() to the 
relax data storage
object SpinContainer.add_item() method.


Modified:
    1.3/data/mol_res_spin.py
    1.3/generic_fns/spin.py

Modified: 1.3/data/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=5445&r1=5444&r2=5445&view=diff
==============================================================================
--- 1.3/data/mol_res_spin.py (original)
+++ 1.3/data/mol_res_spin.py Tue Apr  8 17:41:04 2008
@@ -107,7 +107,19 @@
     def add_item(self, spin_name=None, spin_num=None, select=True):
         """Function for appending an empty container to the list."""
 
-        self.append(SpinContainer(spin_name, spin_num, select))
+        # Test if the spin number already exists.
+        for i in xrange(len(self)):
+            if self[i].num == spin_num:
+                raise RelaxError, "The spin number '" + `spin_num` + "' 
already exists."
+
+        # If no spin data exists, replace the empty first spin with this 
spin.
+        if self[0].num == None and self[0].name == None and len(self) == 1:
+            self[0].num = spin_num
+            self[0].name = spin_name
+
+        # Append the spin.
+        else:
+            self.append(SpinContainer(spin_name, spin_num, select))
 
 
 

Modified: 1.3/generic_fns/spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/spin.py?rev=5445&r1=5444&r2=5445&view=diff
==============================================================================
--- 1.3/generic_fns/spin.py (original)
+++ 1.3/generic_fns/spin.py Tue Apr  8 17:41:04 2008
@@ -133,19 +133,8 @@
     else:
         res_to_cont = 
relax_data_store[relax_data_store.current_pipe].mol[0].res[0]
 
-    # Test if the spin number already exists.
-    for i in xrange(len(res_to_cont.spin)):
-        if res_to_cont.spin[i].num == spin_num:
-            raise RelaxError, "The spin number '" + `spin_num` + "' already 
exists."
-
-    # If no spin data exists, replace the empty first spin with this spin.
-    if res_to_cont.spin[0].num == None and res_to_cont.spin[0].name == None 
and len(res_to_cont.spin) == 1:
-        res_to_cont.spin[0].num = spin_num
-        res_to_cont.spin[0].name = spin_name
-
-    # Append the spin.
-    else:
-        res_to_cont.spin.add_item(spin_num=spin_num, spin_name=spin_name)
+    # Add the spin.
+    res_to_cont.spin.add_item(spin_num=spin_num, spin_name=spin_name)
 
 
 def delete(spin_id=None):




Related Messages


Powered by MHonArc, Updated Tue Apr 08 18:40:10 2008