mailr14878 - /1.3/generic_fns/align_tensor.py


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

Header


Content

Posted by edward on October 18, 2011 - 10:39:
Author: bugman
Date: Tue Oct 18 10:39:11 2011
New Revision: 14878

URL: http://svn.gna.org/viewcvs/relax?rev=14878&view=rev
Log:
Created the alignment tensor module num_tensors() method for counting tensors.

This excludes fixed tensors by default.


Modified:
    1.3/generic_fns/align_tensor.py

Modified: 1.3/generic_fns/align_tensor.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/align_tensor.py?rev=14878&r1=14877&r2=14878&view=diff
==============================================================================
--- 1.3/generic_fns/align_tensor.py (original)
+++ 1.3/generic_fns/align_tensor.py Tue Oct 18 10:39:11 2011
@@ -1041,6 +1041,31 @@
         sys.stdout.write("\n")
 
 
+def num_tensors(skip_fixed=True):
+    """Count the number of tensors.
+
+    @keyword skip_fixed:    If set to True, then only the tensors without 
the fixed flag will be counted.  If set to False, then all tensors will be 
counted.
+    @type fixed:            bool
+    @return:                The number of tensors (excluding fixed tensors 
by default).
+    @rtype:                 int
+    """
+
+    # Init.
+    count = 0
+
+    # Loop over the tensors.
+    for tensor_cont in cdp.align_tensors:
+        # Skip fixed tensors.
+        if skip_fixed and tensor_cont.fixed:
+            continue
+
+        # Increment.
+        count += 1
+
+    # Return the count.
+    return count
+
+
 def reduction(full_tensor=None, red_tensor=None):
     """Specify which tensor is a reduction of which other tensor.
 




Related Messages


Powered by MHonArc, Updated Tue Oct 18 11:00:02 2011