mailr9727 - /branches/bmrb/bmrblib/base_classes.py


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

Header


Content

Posted by edward on October 11, 2009 - 16:59:
Author: bugman
Date: Sun Oct 11 16:59:52 2009
New Revision: 9727

URL: http://svn.gna.org/viewcvs/relax?rev=9727&view=rev
Log:
TagTable.create_tag_table() now handles single element data.

This allows the single element data to be submitted simultaneously with list 
data.


Modified:
    branches/bmrb/bmrblib/base_classes.py

Modified: branches/bmrb/bmrblib/base_classes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/base_classes.py?rev=9727&r1=9726&r2=9727&view=diff
==============================================================================
--- branches/bmrb/bmrblib/base_classes.py (original)
+++ branches/bmrb/bmrblib/base_classes.py Sun Oct 11 16:59:52 2009
@@ -113,6 +113,22 @@
                 tag_names.append(self.tag_names_full[key])
                 tag_values.append(getattr(self.sf, name))
 
+        # Check the input data to avoid cryptic pystarlib error messages.
+        N = len(tag_values[0])
+        for i in range(len(tag_values)):
+            if len(tag_values[i]) > N:
+                # Mismatch.
+                if N != 1:
+                    raise NameError("The tag values are not all the same 
length '%s'." % tag_values)
+
+                # First element was single.
+                N = len(tag_values[i])
+
+        # Fix the single values if the other data are lists.
+        for i in range(len(tag_values)):
+            if len(tag_values[i]) == 1:
+                tag_values[i] = tag_values[i] * N
+
         # Add the data and return the table.
         return TagTable(free=free, tagnames=tag_names, tagvalues=tag_values)
 




Related Messages


Powered by MHonArc, Updated Sun Oct 11 17:20:02 2009