def test_qsat_data(self): dist = { 0: { 'count': 36, 'to': 1, 'from': 0 }, 40: { 'count': 5, 'to': 50, 'from': 40 }, 3: { 'count': 1, 'to': 4, 'from': 3 }, 20: { 'count': 5, 'to': 30, 'from': 20 }, 30: { 'count': 27, 'to': 40, 'from': 30 } } data = SecondAggregateData(SecondAggregateDataTotalItem()) data.cumulative.times_dist = dist data.cumulative.total_count = 74 self.qsat_absrel.timing = 30 self.qsat_absrel.notify(data) self.assertEquals(56.75675675675676, self.qsat_absrel.data[0])
def callback(self, data): self.data = SecondAggregateData(data, SecondAggregateDataTotalItem())
def get_aggregate_data(self, filename): return SecondAggregateData(SecondAggregateDataTotalItem())
def test_total_quantiles(self): self.foo = SecondAggregateDataTotalItem() self.foo.total_count = 1000 self.foo.times_dist = { 2: { 'count': 14, 'to': 3, 'from': 2 }, 3: { 'count': 815, 'to': 4, 'from': 3 }, 4: { 'count': 55, 'to': 5, 'from': 4 }, 5: { 'count': 29, 'to': 6, 'from': 5 }, 6: { 'count': 26, 'to': 7, 'from': 6 }, 7: { 'count': 27, 'to': 8, 'from': 7 }, 8: { 'count': 14, 'to': 9, 'from': 8 }, 9: { 'count': 8, 'to': 10, 'from': 9 }, 10: { 'count': 12, 'to': 20, 'from': 10 } } res = self.foo.calculate_total_quantiles() exp = { 98.0: 9, 99.0: 20, 100.0: 20, 75.0: 4, 80.0: 4, 50.0: 4, 25.0: 4, 90.0: 6, 95.0: 8 } self.assertDictEqual(exp, res)