annotate python/tests/utils.txt @ 366:90bdabc06e9f

updated LCSS to be more generic with a single similarity function
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 15 Jul 2013 12:12:47 -0400
parents efd4dd4665ac
children 2db4e76599a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
1 >>> from utils import *
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
2 >>> from moving import Point
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
3
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
4 >>> computeChi2([],[])
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
5 0.0
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
6 >>> computeChi2(range(1,10),range(1,10))
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
7 0.0
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
8 >>> computeChi2(range(1,9),range(1,10))
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
9 0.0
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
10
32
48e56179c39e added ceil function
Nicolas Saunier <nico@confins.net>
parents: 31
diff changeset
11 >>> ceilDecimals(1.23, 0)
48e56179c39e added ceil function
Nicolas Saunier <nico@confins.net>
parents: 31
diff changeset
12 2.0
48e56179c39e added ceil function
Nicolas Saunier <nico@confins.net>
parents: 31
diff changeset
13 >>> ceilDecimals(1.23, 1)
48e56179c39e added ceil function
Nicolas Saunier <nico@confins.net>
parents: 31
diff changeset
14 1.3
48e56179c39e added ceil function
Nicolas Saunier <nico@confins.net>
parents: 31
diff changeset
15
152
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 42
diff changeset
16 >>> inBetween(1,2,1.5)
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 42
diff changeset
17 True
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 42
diff changeset
18 >>> inBetween(2.1,1,1.5)
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 42
diff changeset
19 True
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 42
diff changeset
20 >>> inBetween(1,2,0)
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 42
diff changeset
21 False
31
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
22
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
23 >>> f = openCheck('non_existant_file.txt')
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
24 File non_existant_file.txt could not be opened.
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
25
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
26 >>> removeExtension('test-adfasdf.asdfa.txt')
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
27 'test-adfasdf.asdfa'
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
28 >>> removeExtension('test-adfasdf')
c000f37c316d moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff changeset
29 'test-adfasdf'
42
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
30
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
31 >>> values = line2Ints('1 2 3 5 6')
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
32 >>> values[0]
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
33 1
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
34 >>> values[-1]
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
35 6
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
36 >>> values = line2Floats('1.3 2.45 7.158e+01 5 6')
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
37 >>> values[0]
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
38 1.3
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
39 >>> values[2] #doctest: +ELLIPSIS
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
40 71.5...
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
41 >>> values[-1]
1a2ac2d4f53a added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 32
diff changeset
42 6.0
285
5957aa1d69e1 Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
43
297
f6f423e25c7f adding function to generate step plots (for cumulative number of vehicles)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 285
diff changeset
44 >>> stepPlot([3, 5, 7, 8], 1, 10, 0)
f6f423e25c7f adding function to generate step plots (for cumulative number of vehicles)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 285
diff changeset
45 ([1, 3, 3, 5, 5, 7, 7, 8, 8, 10], [0, 0, 1, 1, 2, 2, 3, 3, 4, 4])
f6f423e25c7f adding function to generate step plots (for cumulative number of vehicles)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 285
diff changeset
46
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
47 >>> LCSS(range(5), range(5), lambda x,y:(abs(x-y) <= 0.1))
285
5957aa1d69e1 Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
48 5
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
49 >>> LCSS(range(1,5), range(5), lambda x,y:(abs(x-y) <= 0.1))
285
5957aa1d69e1 Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
50 4
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
51 >>> LCSS(range(5,10), range(5), lambda x,y:(abs(x-y) <= 0.1))
285
5957aa1d69e1 Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
52 0
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
53 >>> LCSS(range(5), range(10), lambda x,y:(abs(x-y) <= 0.1))
322
28661c5887d3 Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 297
diff changeset
54 5
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
55 >>> LCSS(range(5), range(10), lambda x,y:(abs(x-y) <= 0.1), 2)
322
28661c5887d3 Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 297
diff changeset
56 5
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
57 >>> LCSS(['a','b','c'], ['a','b','c', 'd'], lambda x,y: x == y)
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
58 3
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
59 >>> LCSS(['a','b','c'], ['a','b','c', 'd'], lambda x,y: x == y, 2)
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
60 3
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
61 >>> LCSS(['a','x','b','c'], ['a','b','c','d','x'], lambda x,y: x == y)
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
62 3
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
63 >>> LCSS(['a','b','c','x','d'], ['a','b','c','d','x'], lambda x,y: x == y)
322
28661c5887d3 Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 297
diff changeset
64 4
28661c5887d3 Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 297
diff changeset
65
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
66 >>> alignedLCSS(range(5), range(5), lambda x,y:(abs(x-y) <= 0.1), 2)
322
28661c5887d3 Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 297
diff changeset
67 5
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
68 >>> alignedLCSS(range(1,5), range(5), lambda x,y:(abs(x-y) <= 0.1), 2)
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
69 4
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
70
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
71 >>> alignedLCSS(range(5,10), range(10), lambda x,y:(abs(x-y) <= 0.1), 2)
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
72 5
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
73 >>> LCSS(range(5,10), range(10), lambda x,y:(abs(x-y) <= 0.1), 2)
322
28661c5887d3 Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 297
diff changeset
74 0
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
75 >>> alignedLCSS(range(5), range(5), lambda x,y:(abs(x-y) <= 0.1), 6)
323
efd4dd4665ac corrected issues with large deltas
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 322
diff changeset
76 5
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
77 >>> alignedLCSS(range(5), range(6), lambda x,y:(abs(x-y) <= 0.1), 6)
323
efd4dd4665ac corrected issues with large deltas
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 322
diff changeset
78 5
366
90bdabc06e9f updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 323
diff changeset
79 >>> alignedLCSS(range(1,7), range(6), lambda x,y:(abs(x-y) <= 0.1), 10)
323
efd4dd4665ac corrected issues with large deltas
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 322
diff changeset
80 5