当前位置: 首页>>代码示例>>Python>>正文


Python Gauged.aggregate_series方法代码示例

本文整理汇总了Python中gauged.Gauged.aggregate_series方法的典型用法代码示例。如果您正苦于以下问题:Python Gauged.aggregate_series方法的具体用法?Python Gauged.aggregate_series怎么用?Python Gauged.aggregate_series使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gauged.Gauged的用法示例。


在下文中一共展示了Gauged.aggregate_series方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_aggregate_series_caching

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import aggregate_series [as 别名]
 def test_aggregate_series_caching(self):
     gauged = Gauged(self.driver, block_size=10000, min_cache_interval=1)
     series = gauged.aggregate_series('foobar', Gauged.MEAN,
         start=0, end=60000, interval=10000)
     self.assertListEqual(series.values, [])
     with gauged.writer as writer:
         writer.add('bar', 50, timestamp=0)
         writer.add('foobar', 50, timestamp=10000)
         writer.add('foobar', 150, timestamp=15000)
         writer.add('foobar', 250, timestamp=20000)
         writer.add('foobar', 350, timestamp=40000)
         writer.add('foobar', 70, timestamp=60000)
     series = gauged.aggregate_series('foobar', Gauged.MEAN,
         start=0, end=60000, interval=10000)
     self.assertListEqual(series.values, [ None, 100, 250, None, 350, None ])
     gauged = Gauged(self.driver, block_size=10000, overwrite_blocks=True, min_cache_interval=1)
     with gauged.writer as writer:
         writer.add('foobar', 150, timestamp=10000)
         writer.add('foobar', 253, timestamp=15000)
         writer.add('foobar', 351, timestamp=20000)
         writer.add('foobar', 450, timestamp=40000)
         writer.add('foobar', 170, timestamp=60000)
     series = gauged.aggregate_series('foobar', Gauged.MEAN,
         start=0, end=60000, interval=10000)
     self.assertListEqual(series.values, [ None, 100, 250, None, 350, None ])
     series = gauged.aggregate_series('foobar', Gauged.MEAN,
         start=0, end=60000, interval=10000, cache=False)
     self.assertListEqual(series.values, [ None, 201.5, 351, None, 450, None ])
     self.driver.remove_cache(0)
     series = gauged.aggregate_series('foobar', Gauged.MEAN,
         start=0, end=60000, interval=10000)
     self.assertListEqual(series.values, [ None, 201.5, 351, None, 450, None ])
     self.assertListEqual(series.timestamps, [ 0, 10000, 20000, 30000, 40000, 50000 ])
开发者ID:lessc0de,项目名称:gauged,代码行数:35,代码来源:test_gauged.py

示例2: test_interval_size_error

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import aggregate_series [as 别名]
 def test_interval_size_error(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('likes', 10)
     with self.assertRaises(GaugedIntervalSizeError):
         gauged.value_series('likes', interval=1)
     with self.assertRaises(GaugedIntervalSizeError):
         gauged.aggregate_series('likes', Gauged.SUM, interval=1)
     with self.assertRaises(GaugedIntervalSizeError):
         gauged.aggregate_series('likes', Gauged.MEAN, interval=1)
开发者ID:pyarnold,项目名称:gauged,代码行数:12,代码来源:test_gauged.py

示例3: test_series_aggregate

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import aggregate_series [as 别名]
 def test_series_aggregate(self):
     gauged = Gauged(self.driver, block_size=10000)
     self.assertEqual(
         len(gauged.aggregate_series('foobar', Gauged.SUM).values), 0)
     with gauged.writer as writer:
         writer.add('foobar', 50, timestamp=10000)
         writer.add('foobar', 150, timestamp=15000)
         writer.add('foobar', 120, timestamp=20000)
         writer.add('foobar', 30, timestamp=25000)
         writer.add('foobar', 40, timestamp=30000)
         writer.add('foobar', 10, timestamp=35000)
         writer.add('bar', 10, timestamp=40000)
     series = gauged.aggregate_series('foobar', Gauged.SUM,
                                      start=10000, end=40000, interval=10000)
     self.assertListEqual(series.values, [200, 150, 50])
     series = gauged.aggregate_series('foobar', Gauged.SUM,
                                      start=10000, end=40000, interval=10000, namespace=1)
     self.assertListEqual(series.values, [])
     series = gauged.aggregate_series('foobar', Gauged.SUM,
                                      start=10000, end=32000, interval=10000)
     self.assertListEqual(series.values, [200, 150, 40])
     series = gauged.aggregate_series('foobar', Gauged.COUNT,
                                      start=10000, end=50000, interval=10000)
     self.assertListEqual(series.values, [2, 2, 2, 0])
     series = gauged.aggregate_series('foobar', Gauged.MIN,
                                      start=12000, end=42000, interval=10000)
     self.assertListEqual(series.values, [120, 30, 10])
     series = gauged.aggregate_series('foobar', Gauged.MAX,
                                      start=12000, end=42000, interval=10000)
     self.assertListEqual(series.values, [150, 40, 10])
开发者ID:pyarnold,项目名称:gauged,代码行数:32,代码来源:test_gauged.py

示例4: test_no_data

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import aggregate_series [as 别名]
 def test_no_data(self):
     gauged = Gauged(self.driver)
     self.assertEqual(len(gauged.namespaces()), 0)
     self.assertEqual(len(gauged.value_series('foo')), 0)
     self.assertEqual(len(gauged.aggregate_series('foo', Gauged.SUM)), 0)
     self.assertEqual(gauged.value('foo'), None)
     self.assertEqual(gauged.aggregate('foo', Gauged.SUM), None)
     self.assertEqual(len(gauged.keys()), 0)
     stats = gauged.statistics()
     for attr in ['data_points', 'byte_count']:
         self.assertEqual(getattr(stats, attr), 0)
开发者ID:pyarnold,项目名称:gauged,代码行数:13,代码来源:test_gauged.py


注:本文中的gauged.Gauged.aggregate_series方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。