# HG changeset patch # User Nicolas Saunier # Date 1359265908 18000 # Node ID 66691c06928c36c79a5d630eb0bfbd983c814154 # Parent fa95796a76b31dfdf9ef78f9cc530f55ae4fe562 first version of indicator LCSS diff -r fa95796a76b3 -r 66691c06928c python/indicators.py --- a/python/indicators.py Sun Jan 27 00:22:55 2013 -0500 +++ b/python/indicators.py Sun Jan 27 00:51:48 2013 -0500 @@ -34,26 +34,26 @@ self.timeInterval = moving.TimeInterval() self.maxValue = maxValue + def __len__(self): + return len(self.values) + def empty(self): return len(self.values) == 0 def __getitem__(self, i): - 'Returns ith value' + 'Returns ith value in time interval' + if i in self.values.keys(): + return self.values[i] + else: + return None + + def getIthValue(self, i): sortedKeys = sorted(self.values.keys()) if 0<=i>> indic1 = TemporalIndicator('bla', [0,3,-4], TimeInterval(4,6)) >>> indic1.empty() False ->>> indic1.valueAtInstant(5) +>>> indic1.getIthValue(1) 3 ->>> indic1.valueAtInstant(3) ->>> indic1[1] -3 ->>> indic1[5] +>>> indic1.getIthValue(3) +>>> indic1[6] +-4 +>>> indic1[7] >>> [v for v in indic1] [0, 3, -4] >>> indic1 = TemporalIndicator('bla', {2:0,4:3,5:-5}) ->>> indic1.valueAtInstant(4) +>>> indic1.getIthValue(1) 3 ->>> indic1.valueAtInstant(3) +>>> indic1.getIthValue(3) >>> indic1[2] --5 +0 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) >>> indicatorMap([1,2,3], t1, 1)