Mercurial Hosting > traffic-intelligence
comparison python/utils.py @ 434:9a714f32fc9f
small updates
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sat, 30 Nov 2013 18:03:35 -0500 |
parents | d40ad901b272 |
children | abe0b2347d4c |
comparison
equal
deleted
inserted
replaced
433:d40ad901b272 | 434:9a714f32fc9f |
---|---|
193 if diff<halfwidth: | 193 if diff<halfwidth: |
194 return 1.-(diff/halfwidth)**2 | 194 return 1.-(diff/halfwidth)**2 |
195 else: | 195 else: |
196 return 0. | 196 return 0. |
197 | 197 |
198 def triangular(center, x, halfwidth): | |
199 diff = abs(center-x) | |
200 if diff<halfwidth: | |
201 return 1.-abs(diff/halfwidth) | |
202 else: | |
203 return 0. | |
198 | 204 |
199 def argMaxDict(d): | 205 def argMaxDict(d): |
200 return max(d.iterkeys(), key=(lambda key: d[key])) | 206 return max(d.iterkeys(), key=(lambda key: d[key])) |
201 | 207 |
202 def framesToTime(nFrames, frameRate, initialTime = time()): | 208 def framesToTime(nFrames, frameRate, initialTime = time()): |