comparison trafficintelligence/tests/tutorials.py @ 1028:cc5cb04b04b0

major update using the trafficintelligence package name and install through pip
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 15 Jun 2018 11:19:10 -0400
parents python/tests/tutorials.py@da665302c88d
children
comparison
equal deleted inserted replaced
1027:6129296848d3 1028:cc5cb04b04b0
1 import unittest
2
3 class TestNGSIM(unittest.TestCase):
4 'Tutorial example for NGSIM data'
5
6 def test_ex1(self):
7 from trafficintelligence import storage
8 objects = storage.loadTrajectoriesFromNgsimFile('../samples/trajectories-0400-0415.txt',100)
9 for o in objects: o.plot()
10
11 class TestTrajectoryLoading(unittest.TestCase):
12 'Tutorial example for NGSIM data'
13
14 def test_ex1(self):
15 from trafficintelligence import storage
16 objects = storage.loadTrajectoriesFromSqlite('../samples/laurier.sqlite', 'object')
17
18 speed = objects[0].getVelocityAtInstant(10).norm2()
19 timeInterval = objects[0].getTimeInterval()
20 speeds = [objects[0].getVelocityAtInstant(t).norm2() for t in range(timeInterval.first, timeInterval.last)]
21 speeds = [v.norm2() for v in objects[0].getVelocities()]
22
23 from matplotlib.pyplot import plot, close, axis
24 plot(range(timeInterval.first, timeInterval.last+1), speeds)
25
26 close('all')
27 objects[0].plot()
28 axis('equal')
29
30 features = storage.loadTrajectoriesFromSqlite('../samples/laurier.sqlite', 'feature')
31 objects[0].setFeatures(features)
32
33 for f in objects[0].features:
34 f.plot()
35 axis('equal')
36
37
38 if __name__ == '__main__':
39 unittest.main()