changeset 659:784298512b60

minor modifications
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 14 May 2015 23:18:44 +0200
parents 6668f541b915
children 994dd644f6ab
files python/moving.py python/utils.py
diffstat 2 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/python/moving.py	Thu May 14 19:48:09 2015 +0200
+++ b/python/moving.py	Thu May 14 23:18:44 2015 +0200
@@ -389,14 +389,16 @@
 def getSYfromXY(p, splines, goodEnoughSplineDistance = 0.5):
     ''' Snap a point p to it's nearest subsegment of it's nearest spline (from the list splines). A spline is a list of points (class Point), most likely a trajectory. 
         
-        Output:
-        =======
-        [spline index, 
-        subsegment leading point index, 
-        snapped point, 
-        subsegment distance, 
-        spline distance,
-        orthogonal point offset]
+    Output:
+    =======
+    [spline index, 
+    subsegment leading point index, 
+    snapped point, 
+    subsegment distance, 
+    spline distance,
+    orthogonal point offset]
+
+    or None
     '''
     minOffsetY = float('inf')
     #For each spline
--- a/python/utils.py	Thu May 14 19:48:09 2015 +0200
+++ b/python/utils.py	Thu May 14 23:18:44 2015 +0200
@@ -253,12 +253,11 @@
     ''' Return a list of categories/values smoothed according to a window. 
         halfWidth is the search radius on either side'''
     from copy import deepcopy
-    catgories = deepcopy(cat_list)
-    smoothed = catgories
-    for point in range(len(catgories)):
+    smoothed = deepcopy(cat_list)
+    for point in range(len(cat_list)):
         lower_bound_check = max(0,point-halfWidth)
-        upper_bound_check = min(len(catgories)-1,point+halfWidth+1)
-        window_values = catgories[lower_bound_check:upper_bound_check]
+        upper_bound_check = min(len(cat_list)-1,point+halfWidth+1)
+        window_values = cat_list[lower_bound_check:upper_bound_check]
         smoothed[point] = max(set(window_values), key=window_values.count)
     return smoothed