Mercurial Hosting > traffic-intelligence
diff python/events.py @ 998:933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 27 May 2018 23:22:48 -0400 |
parents | 030b16ab4f64 |
children |
line wrap: on
line diff
--- a/python/events.py Fri May 25 18:15:18 2018 -0400 +++ b/python/events.py Sun May 27 23:22:48 2018 -0400 @@ -21,7 +21,7 @@ routeSim={} lcss = utils.LCSS(similarityFunc=lambda x,y: (distanceForLCSS(x,y) <= spatialThreshold),delta=delta) for y in prototypesRoutes: - if y in prototypes.keys(): + if y in prototypes: prototypesIDs=prototypes[y] similarity=[] for x in prototypesIDs: @@ -37,7 +37,7 @@ def getRoute(obj,prototypes,objects,noiseEntryNums,noiseExitNums,useDestination=True): route=(obj.startRouteID,obj.endRouteID) if useDestination: - if route not in prototypes.keys(): + if route not in prototypes: route= findRoute(prototypes,objects,route,obj.getNum(),noiseEntryNums,noiseExitNums) return route @@ -153,7 +153,7 @@ '''Returns list of indicator values at instant as dict (with keys from indicators dict)''' values = {} - for k, indicator in self.indicators.iteritems(): + for k, indicator in self.indicators.items(): values[k] = indicator[instant] return values @@ -225,7 +225,7 @@ else: commonTimeInterval = self.timeInterval self.collisionPoints, crossingZones = predictionParameters.computeCrossingsCollisions(self.roadUser1, self.roadUser2, collisionDistanceThreshold, timeHorizon, computeCZ, debug, commonTimeInterval) - for i, cps in self.collisionPoints.iteritems(): + for i, cps in self.collisionPoints.items(): TTCs[i] = prediction.SafetyPoint.computeExpectedIndicator(cps) collisionProbabilities[i] = sum([p.probability for p in cps]) if len(TTCs) > 0: @@ -236,7 +236,7 @@ if computeCZ: self.crossingZones = crossingZones pPETs = {} - for i, cz in self.crossingZones.iteritems(): + for i, cz in self.crossingZones.items(): pPETs[i] = prediction.SafetyPoint.computeExpectedIndicator(cz) self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[9], pPETs, mostSevereIsMax=False)) # TODO add probability of collision, and probability of successful evasive action @@ -269,10 +269,10 @@ interactions = [] num = 0 - for i in xrange(len(objects)): + for i in range(len(objects)): if _others is None: others = objects[:i] - for j in xrange(len(others)): + for j in range(len(others)): commonTimeInterval = objects[i].commonTimeInterval(others[j]) if not commonTimeInterval.empty(): interactions.append(Interaction(num, commonTimeInterval, objects[i].num, others[j].num, objects[i], others[j]))