Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 635:6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 24 Mar 2015 14:17:12 +0100 |
parents | f410c8fb07b7 |
children | 3058e00887bc |
comparison
equal
deleted
inserted
replaced
634:b61b309cb9da | 635:6ae68383071e |
---|---|
1178 indices, intersections = self.positions.getIntersections(p1, p2) | 1178 indices, intersections = self.positions.getIntersections(p1, p2) |
1179 return [t+self.getFirstInstant() for t in indices] | 1179 return [t+self.getFirstInstant() for t in indices] |
1180 | 1180 |
1181 @staticmethod | 1181 @staticmethod |
1182 def computePET(obj1, obj2, collisionDistanceThreshold): | 1182 def computePET(obj1, obj2, collisionDistanceThreshold): |
1183 '''Post-encroachment time based on distance threshold''' | 1183 '''Post-encroachment time based on distance threshold |
1184 | |
1185 Returns the smallest time difference when the object positions are within collisionDistanceThreshold''' | |
1184 #for i in xrange(int(obj1.length())-1): | 1186 #for i in xrange(int(obj1.length())-1): |
1185 # for j in xrange(int(obj2.length())-1): | 1187 # for j in xrange(int(obj2.length())-1): |
1186 # inter = segmentIntersection(obj1.getPositionAt(i), obj1.getPositionAt(i+1), obj2.getPositionAt(i), obj2.getPositionAt(i+1)) | 1188 # inter = segmentIntersection(obj1.getPositionAt(i), obj1.getPositionAt(i+1), obj2.getPositionAt(i), obj2.getPositionAt(i+1)) |
1187 from scipy.spatial.distance import cdist | 1189 from scipy.spatial.distance import cdist |
1188 from numpy import zeros | 1190 from numpy import zeros |
1552 suite = doctest.DocFileSuite('tests/moving.txt') | 1554 suite = doctest.DocFileSuite('tests/moving.txt') |
1553 #suite = doctest.DocTestSuite() | 1555 #suite = doctest.DocTestSuite() |
1554 unittest.TextTestRunner().run(suite) | 1556 unittest.TextTestRunner().run(suite) |
1555 #doctest.testmod() | 1557 #doctest.testmod() |
1556 #doctest.testfile("example.txt") | 1558 #doctest.testfile("example.txt") |
1559 if shapelyAvailable: | |
1560 suite = doctest.DocFileSuite('tests/moving_shapely.txt') | |
1561 unittest.TextTestRunner().run(suite) |