Esempio n. 1
0
 def test_max(self):
     s = series_factory()
     r1 = Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     r2 = Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     r3 = Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     r4 = Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls1 = LimitedSeries(s, start=r1.timestamp, end=r3.timestamp,
                         max_points=3)
     ls2 = LimitedSeries(s, start=r2.timestamp, end=r4.timestamp,
                         max_points=3)
     lsg = LimitedSeriesGroup([ls1, ls2])
     self.assertEqual(lsg.max(), 5.0)
Esempio n. 2
0
 def test_box_data(self):
     s = series_factory()
     r1 = Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     r2 = Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     r3 = Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     r4 = Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls1 = LimitedSeries(s, start=r1.timestamp, end=r3.timestamp,
                         max_points=3)
     ls2 = LimitedSeries(s, start=r2.timestamp, end=r4.timestamp,
                         max_points=3)
     lsg = LimitedSeriesGroup([ls1, ls2])
     r = lsg.box_data()
     self.assertEqual(r['max'], 5.0)
     self.assertEqual(r['min'], 1.0)
     self.assertEqual(r['count'], 2)
     self.assertEqual(r['series'][0]['min'], 0.0)
Esempio n. 3
0
 def test_sum(self):
     s = series_factory()
     r1 = Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     r2 = Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls = LimitedSeries(s, start=r1.timestamp, end=r2.timestamp,
                        max_points=3)
     self.assertEqual(ls.sum(), 15.0)
Esempio n. 4
0
 def test_stddev(self):
     s = series_factory()
     Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     r1 = Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     r2 = Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls = LimitedSeries(s, start=r1.timestamp, end=r2.timestamp,
                        max_points=3)
     self.assertTrue(0.81 < ls.stddev() < 0.82)
Esempio n. 5
0
 def test_range_data(self):
     s = series_factory()
     Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     r1 = Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     r2 = Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls = LimitedSeries(s, start=r1.timestamp, end=r2.timestamp,
                        max_points=3)
     self.assertEqual(ls.range_data(), [2.0, 3.0, 4.0])
     self.assertEqual(ls.range_data(max_points=1), [2.0])
Esempio n. 6
0
 def test_create(self):
     s = series_factory()
     Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls = LimitedSeries(s, start=1, end=2, max_points=3)
     self.assertEqual(ls.max_points, 3)
     self.assertEqual(ls.start, 1)
     self.assertEqual(ls.end, 2)
Esempio n. 7
0
 def test_create_defaults(self):
     s = series_factory()
     rows = [
         Row.objects.create(series=s, timestamp=datetime.now(), value=1.0),
         Row.objects.create(series=s, timestamp=datetime.now(), value=2.0),
         Row.objects.create(series=s, timestamp=datetime.now(), value=3.0),
         Row.objects.create(series=s, timestamp=datetime.now(), value=4.0),
         Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)]
     ls = LimitedSeries(s)
     self.assertEqual(ls.max_points, 5)
     self.assertEqual(ls.start, rows[0].timestamp)
     self.assertEqual(ls.end, rows[-1].timestamp)
Esempio n. 8
0
 def test_box_data(self):
     s = series_factory()
     r1 = Row.objects.create(series=s, timestamp=datetime.now(), value=1.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=2.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=3.0)
     Row.objects.create(series=s, timestamp=datetime.now(), value=4.0)
     r2 = Row.objects.create(series=s, timestamp=datetime.now(), value=5.0)
     ls = LimitedSeries(s, start=r1.timestamp, end=r2.timestamp,
                        max_points=3)
     r = ls.box_data()
     self.assertEqual(r['min'], 0.0)
     self.assertEqual(r['max'], 100.0)
     self.assertEqual(r['lq'], 25.0)
     self.assertEqual(r['uq'], 75.0)
     self.assertEqual(r['median'], 50.0)