diff python/prediction.py @ 636:3058e00887bc

removed all issues because of tests with None, using is instead of == or !=
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 24 Mar 2015 18:11:28 +0100
parents 69a98f84f3eb
children 335f6641bf7a
line wrap: on
line diff
--- a/python/prediction.py	Tue Mar 24 14:17:12 2015 +0100
+++ b/python/prediction.py	Tue Mar 24 18:11:28 2015 +0100
@@ -276,7 +276,7 @@
                         #if (et1.predictPosition(t1)-et2.predictPosition(t2)).norm2() < collisionDistanceThreshold:
                         #    cz = (et1.predictPosition(t1)+et2.predictPosition(t2)).multiply(0.5)
                         cz = moving.segmentIntersection(et1.predictPosition(t1), et1.predictPosition(t1+1), et2.predictPosition(t2), et2.predictPosition(t2+1))
-                        if cz != None:
+                        if cz is not None:
                             deltaV= (et1.predictPosition(t1)- et1.predictPosition(t1+1) - et2.predictPosition(t2)+ et2.predictPosition(t2+1)).norm2()
                             crossingZones.append(SafetyPoint(cz, et1.probability*et2.probability, abs(t1-t2)-(float(collisionDistanceThreshold)/deltaV)))
                         t2 += 1
@@ -500,7 +500,7 @@
             v2 = obj2.getVelocityAtInstant(currentInstant)
             intersection = moving.intersection(p1, p1+v1, p2, p2+v2)
 
-            if intersection != None:
+            if intersection is not None:
                 dp1 = intersection-p1
                 dp2 = intersection-p2
                 dot1 = moving.Point.dot(dp1, v1)
@@ -532,11 +532,11 @@
             #     p2 = secondUser.getPositionAtInstant(currentInstant)
             #     v2 = secondUser.getVelocityAtInstant(currentInstant)
             #     indices, intersections = firstUser.getPositions().getLineIntersections(p2, p2+v2)
-            #     if indices != None:
+            #     if indices is not None:
             #         pass
             #     else: # one has to predict !!!
     
-        if debug and intersection!= None:
+        if debug and intersection is not None:
             from matplotlib.pyplot import plot, figure, axis, title
             figure()
             plot([p1.x, intersection.x], [p1.y, intersection.y], 'r')
@@ -567,7 +567,7 @@
         v2 = obj2.getVelocityAtInstant(currentInstant)
         intersection = moving.intersection(p1, p1+v1, p2, p2+v2)
 
-        if intersection != None:
+        if intersection is not None:
             ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold)
             if ttc:
                 return [SafetyPoint(intersection, 1., ttc)], [] # (p1+v1.multiply(ttc)+p2+v2.multiply(ttc)).multiply(0.5)