-
Notifications
You must be signed in to change notification settings - Fork 0
/
vev.py
39 lines (30 loc) · 1.14 KB
/
vev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import math
import logging
class Vev(object):
"""Vev object
"""
def __init__(self, datadict):
""" Creates a vev object, needs a dict with value at each config"""
self.data = datadict
self.configs = datadict.keys()
self.numconfigs = len(datadict.keys())
logging.debug("created vev with %d configs", self.numconfigs)
def __getitem__(self, key):
return self.data[key]
def __setitem__(self, key, value):
self.data[key] = value
def get(self, config):
return self.data[config]
def average(self):
return math.fsum(self.data.values()) / float(self.numconfigs)
def jackknife(self):
if self.numconfigs > 1:
return {cfg: (math.fsum(self.data.values()) - self.get(cfg)) / (self.numconfigs - 1)
for cfg in self.configs}
else:
return {cfg: (math.fsum(self.data.values()) - self.get(cfg)) for cfg in self.configs}
def writefullfile(self, filename):
outfile = open(filename, 'w')
for config in self.configs:
outfile.write("{!r}\n".format(self[config]))
outfile.close()