Mercurial Hosting > traffic-intelligence
diff python/utils.py @ 241:ee1caff48b03
added function to sort to list of paired data X,Y
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 11 Jul 2012 16:47:49 -0400 |
parents | 584613399513 |
children | 571ba5ed22e2 |
line wrap: on
line diff
--- a/python/utils.py Wed Jul 11 16:30:23 2012 -0400 +++ b/python/utils.py Wed Jul 11 16:47:49 2012 -0400 @@ -164,6 +164,14 @@ # maths section ######################### +def sortXY(X,Y): + 'returns the sorted (x, Y(x)) sorted on X' + D = {} + for x, y in zip(X,Y): + D[x]=y + xsorted = sorted(D.keys()) + return xsorted, [D[x] for x in xsorted] + def ceilDecimals(v, nDecimals): '''Rounds the number at the nth decimal eg 1.23 at 0 decimal is 2, at 1 decimal is 1.3'''