changeset 323:efd4dd4665ac

corrected issues with large deltas
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 08 May 2013 00:19:28 +0200
parents 28661c5887d3
children 99ca91a46007
files python/tests/utils.txt python/utils.py
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/python/tests/utils.txt	Tue May 07 18:43:40 2013 +0200
+++ b/python/tests/utils.txt	Wed May 08 00:19:28 2013 +0200
@@ -64,3 +64,9 @@
 5
 >>> LCSS(range(5,10), range(10), 0.1, lambda x,y:abs(x-y), 2)
 0
+>>> alignedLCSS(range(5), range(5), 0.1, lambda x,y:abs(x-y), 6)
+5
+>>> alignedLCSS(range(5), range(6), 0.1, lambda x,y:abs(x-y), 6)
+5
+>>> alignedLCSS(range(1,7), range(6), 0.1, lambda x,y:abs(x-y), 10)
+5
--- a/python/utils.py	Tue May 07 18:43:40 2013 +0200
+++ b/python/utils.py	Wed May 08 00:19:28 2013 +0200
@@ -210,11 +210,11 @@
         l2 = _l2
     n1 = len(l1)
     n2 = len(l2)
-    # for i in xrange(delta, n1+n2-delta): # i is the alignment of the end of l1 in l2
+    # for i in xrange(min(delta,n1), max(n1+n2-delta, n2+1)): # i is the alignment of the end of l1 in l2
     #     print l1[min(-i-1,n1):] # min(n1+n2-i,n1)
     #     print l2[max(0,i-n1):]
     #     print LCSS(l1[min(-i-1,n1):], l2[max(0,i-n1):], threshold, distance, delta)
-    lcss = [LCSS(l1[min(-i-1,n1):], l2[max(0,i-n1):], threshold, distance, delta) for i in xrange(delta, n1+n2-delta)]
+    lcss = [LCSS(l1[min(-i-1,n1):], l2[max(0,i-n1):], threshold, distance, delta) for i in xrange(min(delta,n1), max(n1+n2-delta, n2+1))]
     return max(lcss)
 
 def normalizedAlignedLCSS(l1, l2, threshold, distance, delta, lengthMethod = min):