6 """Class that contains the output of one replica, used by the
9 def __init__(self, filename):
10 self.filename = filename
13 def create_category(self, name):
16 def create_entry(self, cat, name):
17 if not cat
in self.data:
18 self.create_category(cat)
19 self.data[cat][name]=[]
21 def add_data(self, cat, name, data):
22 self.data[cat][name].append(data)
25 """checks if all entries have same length and are of constant type"""
29 for name
in self.data[cat]:
31 goodlen = len(self.data[cat][name])
32 if len(self.data[cat][name]) != goodlen:
33 print "category %s entry %s : length %s expected, got %s"\
34 % (cat, name, goodlen, len(self.data[cat][name]))
36 goodtype = type(self.data[cat][name][0])
37 for ent
in self.data[cat][name]:
38 if type(ent) != goodtype:
39 print "category %s entry %s : %s expected, got %s"\
40 % (cat, name, goodtype, type(ent))
43 def get_data(self, cat, name):
44 return self.data[cat][name]
46 def get_categories(self):
47 i=sorted(self.data.keys())
53 def get_entries(self,cat):
54 i=sorted(self.data[cat].keys())
62 for name
in self.data[cat]:
63 self.data[cat][name] = [i
for i
in self.data[cat][name] \
66 def toc(self, out=sys.stdout):
67 """print the "table of contents" of this History
68 tendency is a comparison of the last 200 frames, and whether it goes up
70 mean100 is the average over the last 100 frames
72 if not type(out) == file:
74 out.write(
"category\tkey_name\tn_frames\ttype\taverage\tstd\tmean100\ttendency\n")
77 for name
in self.data[cat]:
78 ent=self.data[cat][name]
88 avg100=mean(ent[-100:])
89 avg200=mean(ent[-200:-100])
92 if st200 ==0
or abs(avg200 - avg100)/st200 > 3:
99 out.write(
"\t%20s\t%12d\t%20s\t%10f\t%10f\t%10f\t%5s\n" % \
100 (name, len(ent),tp,avg,st,avg100,tend))
104 out.write(
"\t%20s\t%12d\t%20s\n" % (name, len(ent),tp))