Mercurial Hosting > traffic-intelligence
annotate python/tests/storage.txt @ 913:1cd878812529
work in progress
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 28 Jun 2017 17:57:06 -0400 |
parents | 000555430b28 |
children | 3a06007a4bb7 |
rev | line source |
---|---|
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 >>> from storage import * |
564
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
2 >>> from StringIO import StringIO |
780
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
3 >>> from moving import MovingObject, Point, TimeInterval, Trajectory, prepareSplines |
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 |
516
bce1fe45d1b2
corrected bugs detected by tests (because of moving functions around modules
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
256
diff
changeset
|
5 >>> f = openCheck('non_existant_file.txt') |
bce1fe45d1b2
corrected bugs detected by tests (because of moving functions around modules
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
256
diff
changeset
|
6 File non_existant_file.txt could not be opened. |
bce1fe45d1b2
corrected bugs detected by tests (because of moving functions around modules
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
256
diff
changeset
|
7 |
564
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
8 >>> nonexistentFilename = "nonexistent" |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
9 >>> loadPrototypeMatchIndexesFromSqlite(nonexistentFilename) |
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 DB Error: no such table: prototypes |
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 [] |
564
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
12 >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') |
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 DB Error: no such table: positions |
256
dc1faa7287bd
added the normal adaptation class
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
215
diff
changeset
|
14 DB Error: no such table: velocities |
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 [] |
564
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
16 >>> from os import remove |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
17 >>> remove(nonexistentFilename) |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
18 |
777
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
19 >>> o1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
20 >>> o1.num = 2 |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
21 >>> o2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
22 >>> o2.num = 3 |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
23 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
24 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
25 >>> objects[0].getNum() == o1.num |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
26 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
27 >>> objects[1].getNum() == o2.num |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
28 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
29 >>> o1.getTimeInterval() == objects[0].getTimeInterval() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
30 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
31 >>> o2.getTimeInterval() == objects[1].getTimeInterval() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
32 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
33 >>> o1.getVelocities() == objects[0].getVelocities() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
34 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
35 >>> o2.getVelocities() == objects[1].getVelocities() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
36 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
37 >>> o1.getPositions() == objects[0].getPositions() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
38 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
39 >>> o2.getPositions() == objects[1].getPositions() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
40 True |
834
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
41 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature', timeStep = 2) |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
42 >>> objects[0].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
43 6 |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
44 >>> objects[1].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
45 5 |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
46 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature', timeStep = 3) |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
47 >>> objects[0].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
48 4 |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
49 >>> objects[1].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
50 4 |
780
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
51 >>> align1 = Trajectory.fromPointList([Point(-1, 0), Point(20, 0)]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
52 >>> align2 = Trajectory.fromPointList([Point(-9, -3), Point(6, 3)]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
53 >>> align1.computeCumulativeDistances() |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
54 >>> align2.computeCumulativeDistances() |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
55 >>> prepareSplines([align1, align2]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
56 >>> o1.projectCurvilinear([align1, align2]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
57 >>> o2.projectCurvilinear([align1, align2]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
58 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'curvilinear') |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
59 >>> addCurvilinearTrajectoriesFromSqlite('test.sqlite', {o.num: o for o in objects}) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
60 >>> o1.curvilinearPositions[3][:2] == objects[0].curvilinearPositions[3][:2] |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
61 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
62 >>> o1.curvilinearPositions[7][:2] == objects[0].curvilinearPositions[7][:2] |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
63 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
64 >>> [str(l) for l in o1.curvilinearPositions.getLanes()] == objects[0].curvilinearPositions.getLanes() |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
65 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
66 >>> o2.curvilinearPositions[2][:2] == objects[1].curvilinearPositions[2][:2] |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
67 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
68 >>> o2.curvilinearPositions[6][:2] == objects[1].curvilinearPositions[6][:2] |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
69 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
70 >>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes() |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
71 True |
777
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
72 >>> remove('test.sqlite') |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
73 |
880
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
74 >>> f1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
75 >>> f1.num = 3 |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
76 >>> f2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
77 >>> f2.num = 4 |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
78 >>> o1 = MovingObject(num = 1, userType = 1) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
79 >>> o1.features = [f1, f2] |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
80 >>> saveTrajectoriesToSqlite('test.sqlite', [o1], 'object') |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
81 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'object', withFeatures = True) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
82 >>> len(objects) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
83 1 |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
84 >>> reloaded1 = objects[0] |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
85 >>> reloaded1.getNum() == o1.getNum() |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
86 True |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
87 >>> reloaded1.getUserType() == o1.getUserType() |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
88 True |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
89 >>> len(reloaded1.featureNumbers) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
90 2 |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
91 >>> len(reloaded1.features) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
92 2 |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
93 >>> reloaded1.getPositionAt(0) == Point.midPoint(f1.getPositionAt(0), f2.getPositionAt(0)) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
94 True |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
95 >>> reloaded1.getPositionAt(5) == Point.midPoint(f1.getPositionAt(5), f2.getPositionAt(5)) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
96 True |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
97 >>> reloaded1.getPositionAt(10) == f1.getPositionAt(10) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
98 True |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
99 >>> set(reloaded1.featureNumbers) == set([f1.num, f2.num]) |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
100 True |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
101 >>> remove('test.sqlite') |
000555430b28
adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
872
diff
changeset
|
102 |
564
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
103 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
104 >>> readline(strio) |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
105 'sadlkfjsdlakjf' |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
106 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
107 >>> readline(strio, ['#']) |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
108 'sadlkfjsdlakjf' |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
109 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
110 >>> readline(strio, ['%']) |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
111 '# asdlfjasdlkj0' |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
112 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
113 >>> readline(strio, '%*$') |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
114 '# asdlfjasdlkj0' |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
115 >>> readline(strio, '%#') |
36605d843be5
modified bug for reading vissim files, cleaned use of readline with multiple type of characters for comments (to ignore)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
116 'sadlkfjsdlakjf' |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
117 |
871
6db83beb5350
work in progress to update gaussian mixtures
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
834
diff
changeset
|
118 >>> from sklearn.mixture import GaussianMixture |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
119 >>> from numpy.random import random_sample |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
120 >>> nPoints = 50 |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
121 >>> points = random_sample(nPoints*2).reshape(nPoints,2) |
871
6db83beb5350
work in progress to update gaussian mixtures
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
834
diff
changeset
|
122 >>> gmm = GaussianMixture(4, covariance_type = 'full') |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
123 >>> tmp = gmm.fit(points) |
872
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
124 >>> gmmId = 0 |
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
125 >>> savePOIs('pois-tmp.sqlite', gmm, 'end', gmmId) |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
126 >>> reloadedGmm = loadPOIs('pois-tmp.sqlite') |
872
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
127 >>> sum(gmm.predict(points) == reloadedGmm[gmmId].predict(points)) == nPoints |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
128 True |
872
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
129 >>> reloadedGmm[gmmId].gmmTypes[0] == 'end' |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
130 True |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
131 >>> remove('pois-tmp.sqlite') |