예제 #1
0
    def update(self, data, config):
        ts = sorted(zip(data['dates'], data['values']))
        self.current.SetLabel('{0}'.format(ts[-1][1]))

        min = timeseries.min(ts)[0]
        self.min_val.SetLabel('{0} ({1})'.
                format(min[1], min[0].strftime('%Y-%m-%d')))
        max = timeseries.max(ts)[0]
        self.max_val.SetLabel('{0} ({1})'.
                format(max[1], max[0].strftime('%Y-%m-%d')))

        self.ave.SetLabel('{0:.2f}'.format(timeseries.mean(ts)[0][1]))
        self.sd.SetLabel('{0:.2f}'.format(timeseries.sd(ts)[0][1]))
        self.zscore.SetLabel('{0:.2f}'.
                format(timeseries.zscore(ts)[0][1]))
예제 #2
0
 def test_min(self):
     ts = [
             (datetime.datetime(2013, 10, 31), 4.53),
             (datetime.datetime(2013, 11, 1), 3.87),
             (datetime.datetime(2013, 11, 4), -2.89),
             (datetime.datetime(2013, 11, 5), -0.18),
             (datetime.datetime(2013, 11, 6), 1.36),
             (datetime.datetime(2013, 11, 7), 6.32),
             (datetime.datetime(2013, 11, 8), 0.51),
             (datetime.datetime(2013, 11, 11), -5.98),
             (datetime.datetime(2013, 11, 12), -6.30),
             (datetime.datetime(2013, 11, 13), 0.51),
             ]
     
     ts_min = timeseries.min(ts)
     expected_result = [(datetime.datetime(2013, 11, 12), -6.30)]
     self.assertEqual(ts_min, expected_result)