Mercurial > hg > nsaunier > traffic-intelligence
comparison python/tests/storage.txt @ 777:ef6dd60be2e1 dev
added function to save feature trajectories
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 05 Feb 2016 17:19:13 -0500 |
| parents | 36605d843be5 |
| children | 1b22d81ef5ff |
comparison
equal
deleted
inserted
replaced
| 776:84420159c5f4 | 777:ef6dd60be2e1 |
|---|---|
| 1 >>> from storage import * | 1 >>> from storage import * |
| 2 >>> from StringIO import StringIO | 2 >>> from StringIO import StringIO |
| 3 >>> from moving import MovingObject, Point, TimeInterval | |
| 3 | 4 |
| 4 >>> f = openCheck('non_existant_file.txt') | 5 >>> f = openCheck('non_existant_file.txt') |
| 5 File non_existant_file.txt could not be opened. | 6 File non_existant_file.txt could not be opened. |
| 6 | 7 |
| 7 >>> nonexistentFilename = "nonexistent" | 8 >>> nonexistentFilename = "nonexistent" |
| 13 DB Error: no such table: velocities | 14 DB Error: no such table: velocities |
| 14 [] | 15 [] |
| 15 >>> from os import remove | 16 >>> from os import remove |
| 16 >>> remove(nonexistentFilename) | 17 >>> remove(nonexistentFilename) |
| 17 | 18 |
| 19 >>> o1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) | |
| 20 >>> o1.num = 2 | |
| 21 >>> o2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) | |
| 22 >>> o2.num = 3 | |
| 23 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') | |
| 24 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') | |
| 25 >>> objects[0].getNum() == o1.num | |
| 26 True | |
| 27 >>> objects[1].getNum() == o2.num | |
| 28 True | |
| 29 >>> o1.getTimeInterval() == objects[0].getTimeInterval() | |
| 30 True | |
| 31 >>> o2.getTimeInterval() == objects[1].getTimeInterval() | |
| 32 True | |
| 33 >>> o1.getVelocities() == objects[0].getVelocities() | |
| 34 True | |
| 35 >>> o2.getVelocities() == objects[1].getVelocities() | |
| 36 True | |
| 37 >>> o1.getPositions() == objects[0].getPositions() | |
| 38 True | |
| 39 >>> o2.getPositions() == objects[1].getPositions() | |
| 40 True | |
| 41 >>> remove('test.sqlite') | |
| 42 | |
| 18 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') | 43 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
| 19 >>> readline(strio) | 44 >>> readline(strio) |
| 20 'sadlkfjsdlakjf' | 45 'sadlkfjsdlakjf' |
| 21 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') | 46 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
| 22 >>> readline(strio, ['#']) | 47 >>> readline(strio, ['#']) |
