diff python/moving.py @ 543:cb213269d330

defensive code for curvilinear trajectory initialization
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 07 Jul 2014 16:59:20 -0400
parents a3add9f751ef
children b5525249eda1
line wrap: on
line diff
--- a/python/moving.py	Mon Jul 07 16:54:10 2014 -0400
+++ b/python/moving.py	Mon Jul 07 16:59:20 2014 -0400
@@ -634,11 +634,13 @@
     lateral coordiante is stored as second coordinate'''
 
     def __init__(self, S = None, Y = None, lanes = None):
-        if S == None or Y == None:
+        if S == None or Y == None or len(S) != len(Y):
             self.positions = [[],[]]
+            if len(S) != len(Y):
+                print("S and Y coordinates of different lengths\nInitializing to empty lists")
         else:
             self.positions = [S,Y]
-        if lanes == None:
+        if lanes == None or len(lanes) != self.length():
             self.lanes = []
         else:
             self.lanes = lanes