diff python/tests/utils.txt @ 369:027e254f0b53

lcss subclass for indicators
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 15 Jul 2013 16:47:09 -0400
parents 2db4e76599a1
children a7af3519687e
line wrap: on
line diff
--- a/python/tests/utils.txt	Mon Jul 15 15:08:53 2013 -0400
+++ b/python/tests/utils.txt	Mon Jul 15 16:47:09 2013 -0400
@@ -44,46 +44,65 @@
 >>> stepPlot([3, 5, 7, 8], 1, 10, 0)
 ([1, 3, 3, 5, 5, 7, 7, 8, 8, 10], [0, 0, 1, 1, 2, 2, 3, 3, 4, 4])
 
->>> LCSS(range(5), range(5), lambda x,y:(abs(x-y) <= 0.1))
+>>> lcss = LCSS(lambda x,y: abs(x-y) <= 0.1)
+>>> lcss.compute(range(5), range(5))
 5
->>> LCSS(range(1,5), range(5), lambda x,y:(abs(x-y) <= 0.1))
+>>> lcss.compute(range(1,5), range(5))
 4
->>> LCSS(range(5,10), range(5), lambda x,y:(abs(x-y) <= 0.1))
+>>> lcss.compute(range(5,10), range(5))
 0
->>> LCSS(range(5), range(10), lambda x,y:(abs(x-y) <= 0.1))
+>>> lcss.compute(range(5), range(10))
 5
->>> LCSS(range(5), range(10), lambda x,y:(abs(x-y) <= 0.1), 2)
+>>> lcss.compute(range(5), range(10), 2)
 5
->>> LCSS(['a','b','c'], ['a','b','c', 'd'], lambda x,y: x == y)
-3
->>> LCSS(['a','b','c'], ['a','b','c', 'd'], lambda x,y: x == y, 2)
+>>> lcss.similarityFunc = lambda x,y: x == y
+>>> lcss.compute(['a','b','c'], ['a','b','c', 'd'])
 3
->>> LCSS(['a','x','b','c'], ['a','b','c','d','x'], lambda x,y: x == y)
+>>> lcss.computeNormalized(['a','b','c'], ['a','b','c', 'd']) #doctest: +ELLIPSIS
+1.0
+>>> lcss.computeNormalized(['a','b','c','x'], ['a','b','c', 'd']) #doctest: +ELLIPSIS
+0.75
+>>> lcss.compute(['a','b','c'], ['a','b','c', 'd'])
 3
->>> LCSS(['a','b','c','x','d'], ['a','b','c','d','x'], lambda x,y: x == y)
+>>> lcss.compute(['a','x','b','c'], ['a','b','c','d','x'])
+3
+>>> lcss.compute(['a','b','c','x','d'], ['a','b','c','d','x'])
 4
->>> LCSS(['a','b','c'], ['a','b','x','x','c'], lambda x,y: x == y, 1)
+>>> lcss.delta = 1
+>>> lcss.compute(['a','b','c'], ['a','b','x','x','c'])
 2
 
->>> LCSS(['a','b','c'], ['a','b','c', 'd'], lambda x,y: x == y, returnSubSequence = True)
-(3, [(0, 0), (1, 1), (2, 2)])
->>> LCSS(['a','b','c'], ['x','a','b','c'], lambda x,y: x == y, returnSubSequence = True)
-(3, [(0, 1), (1, 2), (2, 3)])
->>> LCSS(['a','g','b','c'], ['a','b','c', 'd'], lambda x,y: x == y, returnSubSequence = True)
-(3, [(0, 0), (2, 1), (3, 2)])
+>>> lcss.delta = float('inf')
+>>> lcss.compute(['a','b','c'], ['a','b','c', 'd'], computeSubSequence = True)
+3
+>>> lcss.subSequenceIndices
+[(0, 0), (1, 1), (2, 2)]
+>>> lcss.compute(['a','b','c'], ['x','a','b','c'], computeSubSequence = True)
+3
+>>> lcss.subSequenceIndices
+[(0, 1), (1, 2), (2, 3)]
+>>> lcss.compute(['a','g','b','c'], ['a','b','c', 'd'], computeSubSequence = True)
+3
+>>> lcss.subSequenceIndices
+[(0, 0), (2, 1), (3, 2)]
 
->>> alignedLCSS(range(5), range(5), lambda x,y:(abs(x-y) <= 0.1), 2)
+>>> alignedLcss = LCSS(lambda x,y:(abs(x-y) <= 0.1), delta = 2, aligned = True)
+>>> alignedLcss.compute(range(5), range(5))
 5
->>> alignedLCSS(range(1,5), range(5), lambda x,y:(abs(x-y) <= 0.1), 2)
+>>> alignedLcss.compute(range(1,5), range(5))
 4
 
->>> alignedLCSS(range(5,10), range(10), lambda x,y:(abs(x-y) <= 0.1), 2)
+>>> alignedLcss.compute(range(5,10), range(10))
 5
->>> LCSS(range(5,10), range(10), lambda x,y:(abs(x-y) <= 0.1), 2)
+
+>>> lcss.delta = 2
+>>> lcss.compute(range(5,10), range(10))
 0
->>> alignedLCSS(range(5), range(5), lambda x,y:(abs(x-y) <= 0.1), 6)
+>>> alignedLcss.delta = 6
+>>> alignedLcss.compute(range(5), range(5))
 5
->>> alignedLCSS(range(5), range(6), lambda x,y:(abs(x-y) <= 0.1), 6)
+>>> alignedLcss.compute(range(5), range(6))
 5
->>> alignedLCSS(range(1,7), range(6), lambda x,y:(abs(x-y) <= 0.1), 10)
+>>> lcss.delta = 10
+>>> alignedLcss.compute(range(1,7), range(6))
 5