Mercurial > hg > nsaunier > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 598:11f96bd08552 | 614:5e09583275a4 |
|---|---|
| 18 >>> inBetween(2.1,1,1.5) | 18 >>> inBetween(2.1,1,1.5) |
| 19 True | 19 True |
| 20 >>> inBetween(1,2,0) | 20 >>> inBetween(1,2,0) |
| 21 False | 21 False |
| 22 | 22 |
| 23 >>> f = openCheck('non_existant_file.txt') | |
| 24 File non_existant_file.txt could not be opened. | |
| 25 | |
| 26 >>> removeExtension('test-adfasdf.asdfa.txt') | 23 >>> removeExtension('test-adfasdf.asdfa.txt') |
| 27 'test-adfasdf.asdfa' | 24 'test-adfasdf.asdfa' |
| 28 >>> removeExtension('test-adfasdf') | 25 >>> removeExtension('test-adfasdf') |
| 29 'test-adfasdf' | 26 'test-adfasdf' |
| 30 | 27 |
| 42 6.0 | 39 6.0 |
| 43 | 40 |
| 44 >>> stepPlot([3, 5, 7, 8], 1, 10, 0) | 41 >>> stepPlot([3, 5, 7, 8], 1, 10, 0) |
| 45 ([1, 3, 3, 5, 5, 7, 7, 8, 8, 10], [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) | 42 ([1, 3, 3, 5, 5, 7, 7, 8, 8, 10], [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) |
| 46 | 43 |
| 47 >>> LCSS(range(5), range(5), 0.1, lambda x,y:abs(x-y)) | 44 >>> mostCommon(['a','b','c','b']) |
| 45 'b' | |
| 46 >>> mostCommon(['a','b','c','b', 'c']) | |
| 47 'b' | |
| 48 >>> mostCommon(range(10)+[1]) | |
| 49 1 | |
| 50 >>> mostCommon([range(2), range(4), range(2)]) | |
| 51 [0, 1] | |
| 52 | |
| 53 >>> lcss = LCSS(lambda x,y: abs(x-y) <= 0.1) | |
| 54 >>> lcss.compute(range(5), range(5)) | |
| 48 5 | 55 5 |
| 49 >>> LCSS(range(1,5), range(5), 0.1, lambda x,y:abs(x-y)) | 56 >>> lcss.compute(range(1,5), range(5)) |
| 50 4 | 57 4 |
| 51 >>> LCSS(range(5,10), range(5), 0.1, lambda x,y:abs(x-y)) | 58 >>> lcss.compute(range(5,10), range(5)) |
| 52 0 | 59 0 |
| 60 >>> lcss.compute(range(5), range(10)) | |
| 61 5 | |
| 62 >>> lcss.compute(range(5), range(10), 2) | |
| 63 5 | |
| 64 >>> lcss.similarityFunc = lambda x,y: x == y | |
| 65 >>> lcss.compute(['a','b','c'], ['a','b','c', 'd']) | |
| 66 3 | |
| 67 >>> lcss.computeNormalized(['a','b','c'], ['a','b','c', 'd']) #doctest: +ELLIPSIS | |
| 68 1.0 | |
| 69 >>> lcss.computeNormalized(['a','b','c','x'], ['a','b','c', 'd']) #doctest: +ELLIPSIS | |
| 70 0.75 | |
| 71 >>> lcss.compute(['a','b','c'], ['a','b','c', 'd']) | |
| 72 3 | |
| 73 >>> lcss.compute(['a','x','b','c'], ['a','b','c','d','x']) | |
| 74 3 | |
| 75 >>> lcss.compute(['a','b','c','x','d'], ['a','b','c','d','x']) | |
| 76 4 | |
| 77 >>> lcss.delta = 1 | |
| 78 >>> lcss.compute(['a','b','c'], ['a','b','x','x','c']) | |
| 79 2 | |
| 53 | 80 |
| 81 >>> lcss.delta = float('inf') | |
| 82 >>> lcss.compute(['a','b','c'], ['a','b','c', 'd'], computeSubSequence = True) | |
| 83 3 | |
| 84 >>> lcss.subSequenceIndices | |
| 85 [(0, 0), (1, 1), (2, 2)] | |
| 86 >>> lcss.compute(['a','b','c'], ['x','a','b','c'], computeSubSequence = True) | |
| 87 3 | |
| 88 >>> lcss.subSequenceIndices | |
| 89 [(0, 1), (1, 2), (2, 3)] | |
| 90 >>> lcss.compute(['a','g','b','c'], ['a','b','c', 'd'], computeSubSequence = True) | |
| 91 3 | |
| 92 >>> lcss.subSequenceIndices | |
| 93 [(0, 0), (2, 1), (3, 2)] | |
| 94 | |
| 95 >>> alignedLcss = LCSS(lambda x,y:(abs(x-y) <= 0.1), delta = 2, aligned = True) | |
| 96 >>> alignedLcss.compute(range(5), range(5)) | |
| 97 5 | |
| 98 >>> alignedLcss.compute(range(1,5), range(5)) | |
| 99 4 | |
| 100 | |
| 101 >>> alignedLcss.compute(range(5,10), range(10)) | |
| 102 5 | |
| 103 | |
| 104 >>> lcss.delta = 2 | |
| 105 >>> lcss.compute(range(5,10), range(10)) | |
| 106 0 | |
| 107 >>> alignedLcss.delta = 6 | |
| 108 >>> alignedLcss.compute(range(5), range(5)) | |
| 109 5 | |
| 110 >>> alignedLcss.compute(range(5), range(6)) | |
| 111 5 | |
| 112 >>> lcss.delta = 10 | |
| 113 >>> alignedLcss.compute(range(1,7), range(6)) | |
| 114 5 | |
| 115 >>> lcss = LCSS(lambda x,y: x == y, delta = 2, aligned = True) | |
| 116 >>> lcss.compute(range(20), [2,4,6,7,8,9,11,13], True) | |
| 117 8 | |
| 118 >>> lcss.subSequenceIndices | |
| 119 [(2, 0), (4, 1), (6, 2), (7, 3), (8, 4), (9, 5), (11, 6), (13, 7)] |
