diff python/indicators.py @ 693:5ee22bf7e4d5 dev

corrected bug when loading indicator time intervals and updated how queries are created for better legibility
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 30 Jun 2015 15:46:31 -0400
parents 9a258687af4c
children b75d0c258ca9
line wrap: on
line diff
--- a/python/indicators.py	Mon Jun 29 23:09:58 2015 -0400
+++ b/python/indicators.py	Tue Jun 30 15:46:31 2015 -0400
@@ -19,21 +19,21 @@
 
     it should have more information like name, unit'''
     
-    def __init__(self, name, values, timeInterval=None, maxValue = None):
+    def __init__(self, name, values, timeInterval = None, maxValue = None):
         self.name = name
-        if timeInterval:
+        if timeInterval is None:
+            self.values = values
+            instants = sorted(self.values.keys())
+            if len(instants) > 0:
+                self.timeInterval = moving.TimeInterval(instants[0], instants[-1])
+            else:
+                self.timeInterval = moving.TimeInterval()
+        else:
             assert len(values) == timeInterval.length()
             self.timeInterval = timeInterval
             self.values = {}
             for i in xrange(int(round(self.timeInterval.length()))):
                 self.values[self.timeInterval[i]] = values[i]
-        else:
-            self.values = values
-            instants = sorted(self.values.keys())
-            if instants:
-                self.timeInterval = moving.TimeInterval(instants[0], instants[-1])
-            else:
-                self.timeInterval = moving.TimeInterval()
         self.maxValue = maxValue
 
     def __len__(self):