[align] Assert all inputs of all items have the same length.
authorSimon Chabot <simon.chabot@logilab.fr>
Tue, 20 Nov 2012 15:07:41 +0100
changeset 155 90412c2a4d9e
parent 154 f30b1c1bd109
child 156 0d248e74b20b
[align] Assert all inputs of all items have the same length.
matrix.py
--- a/matrix.py	Tue Nov 20 15:06:33 2012 +0100
+++ b/matrix.py	Tue Nov 20 15:07:41 2012 +0100
@@ -118,10 +118,14 @@
        matrices are summed with their own weighting and the result is the global
        alignment matrix, which is returned.
 
-       /!\ All `input1` and `input2` of each tuple must have the same size
-           in twos
-      XXX Write an assertion
     """
+
+    #Assert all items have the same size
+    size1, size2 = len(items[0][1]), len(items[0][2])
+    for item in items[1:]:
+        assert size1 == len(item[1])
+        assert size2 == len(item[2])
+
     globalmatrix = items[0][0]*cdist(*items[0][1:])
     for item in items[1:]:
         globalmatrix += item[0]*cdist(*item[1:])