Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/tests/storage.txt @ 1204:a12d126346ff
merge
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 22 Mar 2023 22:01:12 -0400 |
| parents | 4356065ed3ca |
| children | 76f5693b530c |
comparison
equal
deleted
inserted
replaced
| 1203:7b3384a8e409 | 1204:a12d126346ff |
|---|---|
| 7 >>> f = openCheck('non_existant_file.txt') | 7 >>> f = openCheck('non_existant_file.txt') |
| 8 File non_existant_file.txt could not be opened. | 8 File non_existant_file.txt could not be opened. |
| 9 | 9 |
| 10 >>> nonexistentFilename = "nonexistent" | 10 >>> nonexistentFilename = "nonexistent" |
| 11 >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') | 11 >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') |
| 12 Impossible to load from non-existing file nonexistent | |
| 12 [] | 13 [] |
| 13 | 14 |
| 14 >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) | 15 >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
| 15 >>> o2 = MovingObject.generate(3, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) | 16 >>> o2 = MovingObject.generate(3, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) |
| 16 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') | 17 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') |
| 114 | 115 |
| 115 >>> from sklearn.mixture import GaussianMixture | 116 >>> from sklearn.mixture import GaussianMixture |
| 116 >>> from numpy.random import random_sample | 117 >>> from numpy.random import random_sample |
| 117 >>> nPoints = 50 | 118 >>> nPoints = 50 |
| 118 >>> points = random_sample(nPoints*2).reshape(nPoints,2) | 119 >>> points = random_sample(nPoints*2).reshape(nPoints,2) |
| 119 >>> gmm = GaussianMixture(4, covariance_type = 'full') | 120 >>> gmm = GaussianMixture(n_components = 4, covariance_type = 'full') |
| 120 >>> tmp = gmm.fit(points) | 121 >>> tmp = gmm.fit(points) |
| 121 >>> gmmId = 0 | 122 >>> gmmId = 0 |
| 122 >>> savePOIsToSqlite('pois-tmp.sqlite', gmm, 'end', gmmId) | 123 >>> savePOIsToSqlite('pois-tmp.sqlite', gmm, 'end', gmmId) |
| 123 >>> reloadedGmm = loadPOIsFromSqlite('pois-tmp.sqlite') | 124 >>> reloadedGmm = loadPOIsFromSqlite('pois-tmp.sqlite') |
| 124 >>> sum(gmm.predict(points) == reloadedGmm[gmmId].predict(points)) == nPoints | 125 >>> sum(gmm.predict(points) == reloadedGmm[gmmId].predict(points)) == nPoints |
