Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 869:eb2f8ce2b39d
added method for longest feature
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 03 Feb 2017 14:16:36 -0500 |
parents | a8ca72dc1564 |
children | d1ff6917d082 |
comparison
equal
deleted
inserted
replaced
868:1fdafa9f6bf4 | 869:eb2f8ce2b39d |
---|---|
1264 if self.hasFeatures() and i<len(self.features): | 1264 if self.hasFeatures() and i<len(self.features): |
1265 return self.features[i] | 1265 return self.features[i] |
1266 else: | 1266 else: |
1267 return None | 1267 return None |
1268 | 1268 |
1269 def getNLongestFeatures(self, nFeatures = 1): | |
1270 if self.features is None: | |
1271 return [] | |
1272 else: | |
1273 tmp = utils.sortByLength(self.getFeatures(), reverse = True) | |
1274 return tmp[:min(len(tmp), nFeatures)] | |
1275 | |
1269 def getFeatureNumbers(self): | 1276 def getFeatureNumbers(self): |
1270 '''Returns the number of features at each instant | 1277 '''Returns the number of features at each instant |
1271 dict instant -> number of features''' | 1278 dict instant -> number of features''' |
1272 if self.hasFeatures(): | 1279 if self.hasFeatures(): |
1273 featureNumbers = {} | 1280 featureNumbers = {} |