diff python/tests/utils.txt @ 614:5e09583275a4

Merged Nicolas/trafficintelligence into default
author Mohamed Gomaa <eng.m.gom3a@gmail.com>
date Fri, 05 Dec 2014 12:13:53 -0500
parents bce1fe45d1b2
children 9990ef119bce
line wrap: on
line diff
--- a/python/tests/utils.txt	Thu Apr 18 15:29:33 2013 -0400
+++ b/python/tests/utils.txt	Fri Dec 05 12:13:53 2014 -0500
@@ -20,9 +20,6 @@
 >>> inBetween(1,2,0)
 False
 
->>> f = openCheck('non_existant_file.txt')
-File non_existant_file.txt could not be opened.
-
 >>> removeExtension('test-adfasdf.asdfa.txt')
 'test-adfasdf.asdfa'
 >>> removeExtension('test-adfasdf')
@@ -44,10 +41,79 @@
 >>> 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), 0.1, lambda x,y:abs(x-y))
+>>> mostCommon(['a','b','c','b'])
+'b'
+>>> mostCommon(['a','b','c','b', 'c'])
+'b'
+>>> mostCommon(range(10)+[1])
+1
+>>> mostCommon([range(2), range(4), range(2)])
+[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), 0.1, lambda x,y:abs(x-y))
+>>> lcss.compute(range(1,5), range(5))
+4
+>>> lcss.compute(range(5,10), range(5))
+0
+>>> lcss.compute(range(5), range(10))
+5
+>>> lcss.compute(range(5), range(10), 2)
+5
+>>> lcss.similarityFunc = lambda x,y: x == y
+>>> lcss.compute(['a','b','c'], ['a','b','c', 'd'])
+3
+>>> 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.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(range(5,10), range(5), 0.1, lambda x,y:abs(x-y))
+>>> lcss.delta = 1
+>>> lcss.compute(['a','b','c'], ['a','b','x','x','c'])
+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 = LCSS(lambda x,y:(abs(x-y) <= 0.1), delta = 2, aligned = True)
+>>> alignedLcss.compute(range(5), range(5))
+5
+>>> alignedLcss.compute(range(1,5), range(5))
+4
+
+>>> alignedLcss.compute(range(5,10), range(10))
+5
+
+>>> lcss.delta = 2
+>>> lcss.compute(range(5,10), range(10))
 0
-
+>>> alignedLcss.delta = 6
+>>> alignedLcss.compute(range(5), range(5))
+5
+>>> alignedLcss.compute(range(5), range(6))
+5
+>>> lcss.delta = 10
+>>> alignedLcss.compute(range(1,7), range(6))
+5
+>>> lcss = LCSS(lambda x,y: x == y, delta = 2, aligned = True)
+>>> lcss.compute(range(20), [2,4,6,7,8,9,11,13], True)
+8
+>>> lcss.subSequenceIndices
+[(2, 0), (4, 1), (6, 2), (7, 3), (8, 4), (9, 5), (11, 6), (13, 7)]