Mercurial Hosting > traffic-intelligence
annotate python/tests/storage.txt @ 1004:75601be6019f
work on process
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 03 Jun 2018 00:21:18 -0400 |
parents | 933670761a57 |
children |
rev | line source |
---|---|
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 >>> from storage import * |
998
933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
927
diff
changeset
|
2 >>> from io 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 >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') |
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 DB Error: no such table: positions |
256
dc1faa7287bd
added the normal adaptation class
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
215
diff
changeset
|
11 DB Error: no such table: velocities |
215
5e2983b05d4e
created first doctest tests for storage
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
12 [] |
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
|
13 >>> 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
|
14 >>> 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
|
15 |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
16 >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
17 >>> o2 = MovingObject.generate(3, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) |
777
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
18 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
19 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
20 >>> objects[0].getNum() == o1.num |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
21 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
22 >>> objects[1].getNum() == o2.num |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
23 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
24 >>> o1.getTimeInterval() == objects[0].getTimeInterval() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
25 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
26 >>> o2.getTimeInterval() == objects[1].getTimeInterval() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
27 True |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
28 >>> o1.getVelocities().length() == objects[0].getVelocities().length() |
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
29 True |
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
30 >>> o2.getVelocities().length() == objects[1].getVelocities().length() |
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
31 True |
777
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
32 >>> o1.getVelocities() == objects[0].getVelocities() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
33 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
34 >>> o2.getVelocities() == objects[1].getVelocities() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
35 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
36 >>> o1.getPositions() == objects[0].getPositions() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
37 True |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
38 >>> o2.getPositions() == objects[1].getPositions() |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
39 True |
834
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
40 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature', timeStep = 2) |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
41 >>> objects[0].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
42 6 |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
43 >>> objects[1].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
44 5 |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
45 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature', timeStep = 3) |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
46 >>> objects[0].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
47 4 |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
48 >>> objects[1].positions.length() |
119c4efe6398
added option to load subsampled trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
49 4 |
780
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
50 >>> 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
|
51 >>> 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
|
52 >>> align1.computeCumulativeDistances() |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
53 >>> align2.computeCumulativeDistances() |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
54 >>> prepareSplines([align1, align2]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
55 >>> o1.projectCurvilinear([align1, align2]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
56 >>> o2.projectCurvilinear([align1, align2]) |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
57 >>> 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
|
58 >>> 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
|
59 >>> 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
|
60 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
61 >>> 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
|
62 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
63 >>> [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
|
64 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
65 >>> 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
|
66 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
67 >>> 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
|
68 True |
1b22d81ef5ff
cleaned and checked storage with functions for curvilinear trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
777
diff
changeset
|
69 >>> [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
|
70 True |
777
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
71 >>> remove('test.sqlite') |
ef6dd60be2e1
added function to save feature trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
564
diff
changeset
|
72 |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
73 >>> f1 = MovingObject.generate(3, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
880
diff
changeset
|
74 >>> f2 = MovingObject.generate(4, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) |
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
|
75 >>> 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
|
76 >>> 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
|
77 >>> 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
|
78 >>> 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
|
79 >>> 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
|
80 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
|
81 >>> 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
|
82 >>> 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
|
83 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
|
84 >>> 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
|
85 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
|
86 >>> 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
|
87 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
|
88 >>> 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
|
89 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
|
90 >>> 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
|
91 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
|
92 >>> 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
|
93 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
|
94 >>> 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
|
95 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
|
96 >>> 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
|
97 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
|
98 >>> 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
|
99 |
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
|
100 >>> 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
|
101 >>> 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
|
102 '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
|
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 '# 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
|
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 >>> 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
|
113 'sadlkfjsdlakjf' |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
114 |
871
6db83beb5350
work in progress to update gaussian mixtures
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
834
diff
changeset
|
115 >>> from sklearn.mixture import GaussianMixture |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
116 >>> from numpy.random import random_sample |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
117 >>> nPoints = 50 |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
118 >>> 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
|
119 >>> gmm = GaussianMixture(4, covariance_type = 'full') |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
120 >>> tmp = gmm.fit(points) |
872
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
121 >>> gmmId = 0 |
927
c030f735c594
added assignment of trajectories to prototypes and cleanup of insert queries
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
918
diff
changeset
|
122 >>> savePOIsToSqlite('pois-tmp.sqlite', gmm, 'end', gmmId) |
c030f735c594
added assignment of trajectories to prototypes and cleanup of insert queries
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
918
diff
changeset
|
123 >>> reloadedGmm = loadPOIsFromSqlite('pois-tmp.sqlite') |
872
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
124 >>> 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
|
125 True |
872
c70adaeeddf5
solved issue with latest version of scikit-learn
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
871
diff
changeset
|
126 >>> reloadedGmm[gmmId].gmmTypes[0] == 'end' |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
127 True |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
780
diff
changeset
|
128 >>> remove('pois-tmp.sqlite') |