本文整理汇总了Python中orddict.OrdDict.place_avg方法的典型用法代码示例。如果您正苦于以下问题:Python OrdDict.place_avg方法的具体用法?Python OrdDict.place_avg怎么用?Python OrdDict.place_avg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orddict.OrdDict
的用法示例。
在下文中一共展示了OrdDict.place_avg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProcessScheduler
# 需要导入模块: from orddict import OrdDict [as 别名]
# 或者: from orddict.OrdDict import place_avg [as 别名]
def ProcessScheduler(self):
def stddev(data):
avg = sum(data) / len(data)
return avg, (sum([(d - avg) ** 2 for d in data]) / len(data)) ** 0.5
data = OrdDict()
data.count = 0
data.match_avg = 0
data.match_stddev = 0
data.place_avg = 0
data.place_stddev = 0
r = re.compile("Scheduled ([0-9]*) items in [0-9.]* = ([0-9.]*) match \+ ([0-9.]*) place")
data = OrdDict()
c = _DB.cursor()
c.execute(
"""SELECT details FROM mythlog
WHERE module='scheduler'
AND message='Scheduled items'"""
)
runs = [r.match(d[0]).groups() for d in c.fetchall()]
if len(runs) == 0:
return {"scheduler": data}
a, s = stddev([float(r[2]) for r in runs])
for i, r in reversed(list(enumerate(runs))):
if abs(float(r[2]) - a) > (3 * s):
runs.pop(i)
data = OrdDict()
count = [float(r[0]) for r in runs]
match = [float(r[1]) for r in runs]
place = [float(r[2]) for r in runs]
data.count = int(sum(count) / len(count))
data.match_avg, data.match_stddev = stddev(match)
data.place_avg, data.place_stddev = stddev(place)
return {"scheduler": data}