Mercurial Hosting > traffic-intelligence
comparison python/indicators.py @ 636:3058e00887bc
removed all issues because of tests with None, using is instead of == or !=
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 24 Mar 2015 18:11:28 +0100 |
parents | 2d1d33ae1c69 |
children | dc70d9e711f5 |
comparison
equal
deleted
inserted
replaced
635:6ae68383071e | 636:3058e00887bc |
---|---|
96 values.append(self.values[key]) | 96 values.append(self.values[key]) |
97 return values | 97 return values |
98 | 98 |
99 | 99 |
100 def l1Distance(x, y): # lambda x,y:abs(x-y) | 100 def l1Distance(x, y): # lambda x,y:abs(x-y) |
101 if x == None or y == None: | 101 if x is None or y is None: |
102 return float('inf') | 102 return float('inf') |
103 else: | 103 else: |
104 return abs(x-y) | 104 return abs(x-y) |
105 | 105 |
106 from utils import LCSS as utilsLCSS | 106 from utils import LCSS as utilsLCSS |
110 def __init__(self, similarityFunc, delta = float('inf'), minLength = 0, aligned = False, lengthFunc = min): | 110 def __init__(self, similarityFunc, delta = float('inf'), minLength = 0, aligned = False, lengthFunc = min): |
111 utilsLCSS.__init__(self, similarityFunc, delta, aligned, lengthFunc) | 111 utilsLCSS.__init__(self, similarityFunc, delta, aligned, lengthFunc) |
112 self.minLength = minLength | 112 self.minLength = minLength |
113 | 113 |
114 def checkIndicator(self, indicator): | 114 def checkIndicator(self, indicator): |
115 return indicator != None and len(indicator) >= self.minLength | 115 return indicator is not None and len(indicator) >= self.minLength |
116 | 116 |
117 def compute(self, indicator1, indicator2, computeSubSequence = False): | 117 def compute(self, indicator1, indicator2, computeSubSequence = False): |
118 if self.checkIndicator(indicator1) and self.checkIndicator(indicator2): | 118 if self.checkIndicator(indicator1) and self.checkIndicator(indicator2): |
119 return self._compute(indicator1.getValues(), indicator2.getValues(), computeSubSequence) | 119 return self._compute(indicator1.getValues(), indicator2.getValues(), computeSubSequence) |
120 else: | 120 else: |