Exemple #1
0
 def test_hist(self):
     h = Circllhist()
     h.insert(123,3)
     h.insert_intscale(1,1)
     self.assertEqual(h.count(), 4)
     self.assertEqual(h.bin_count(), 2)
     self.assertAlmostEqual(h.sum(), 385.5)
     self.assertAlmostEqual(h.mean(), 96.375)
     self.assertAlmostEqual(h.quantile(0.5), 123.333, 1)
     self.assertTrue(str(h))
     g = Circllhist.from_dict(h.to_dict())
     self.assertEqual(h.sum(), g.sum())
     h.merge(g)
     f = Circllhist.from_b64(h.to_b64())
     self.assertEqual(h.sum(), f.sum())
     h.clear()
     self.assertEqual(h.count(), 0)
Exemple #2
0
 def test_hist(self):
     h = Circllhist()
     h.insert(123, 3)
     h.insert_intscale(1, 1)
     self.assertEqual(h.count(), 4)
     self.assertEqual(h.bin_count(), 2)
     self.assertAlmostEqual(h.sum(), 385.5)
     self.assertAlmostEqual(h.mean(), 96.375)
     self.assertAlmostEqual(h.quantile(0.5), 123.333, 1)
     self.assertTrue(str(h))
     g = Circllhist.from_dict(h.to_dict())
     self.assertEqual(h.sum(), g.sum())
     h.merge(g)
     f = Circllhist.from_b64(h.to_b64())
     self.assertEqual(h.sum(), f.sum())
     h.clear()
     self.assertEqual(h.count(), 0)
Exemple #3
0
 def test_hist(self):
     h = Circllhist()
     h.insert(123, 3)
     h.insert_intscale(1, 1)
     self.assertEqual(h.count(), 4)
     self.assertEqual(h.bin_count(), 2)
     self.assertAlmostEqual(h.sum(), 384.87619047)
     self.assertAlmostEqual(h.mean(), 96.2190476)
     self.assertAlmostEqual(h.quantile(0.5), 122.5, 1)
     self.assertAlmostEqual(h.quantile(0.5, qtype=7), 122.5, 1)
     self.assertTrue(str(h))
     g = Circllhist.from_dict(h.to_dict())
     self.assertEqual(h.sum(), g.sum())
     h.merge(g)
     print(h.to_b64())
     f = Circllhist.from_b64(h.to_b64())
     self.assertEqual(h.sum(), f.sum())
     h.clear()
     self.assertEqual(h.count(), 0)
 def fmt(rec):
     # raise Exception("Can't fetch histogram data from a numeric metric")
     h = Circllhist()
     if rec[kind]:
         h.insert(rec[kind])
     return h