added stats code to check stability
util/stats/db.py: added working listticks (for printing) and retticks(for using in python) code util/stats/stats.py: added stability function that checks if all samples are within 10% of mean. --HG-- extra : convert_revision : 7eb1714db75e456f248fe7cae73db1c57642947d
This commit is contained in:
parent
3e5a3df24f
commit
dfecc89150
|
@ -207,16 +207,43 @@ class Database(object):
|
||||||
|
|
||||||
# Name: listTicks
|
# Name: listTicks
|
||||||
# Desc: Prints all samples for a given run
|
# Desc: Prints all samples for a given run
|
||||||
def listTicks(self, run=None):
|
def listTicks(self, runs=None):
|
||||||
print "tick"
|
print "tick"
|
||||||
print "----------------------------------------"
|
print "----------------------------------------"
|
||||||
sql = 'select distinct dt_tick from data where dt_stat=1950'
|
sql = 'select distinct dt_tick from data where dt_stat=1180 and ('
|
||||||
#if run != None:
|
if runs != None:
|
||||||
# sql += ' where dt_run=%d' % run
|
first = True
|
||||||
|
for run in runs:
|
||||||
|
if first:
|
||||||
|
# sql += ' where'
|
||||||
|
first = False
|
||||||
|
else:
|
||||||
|
sql += ' or'
|
||||||
|
sql += ' dt_run=%s' % run.run
|
||||||
|
sql += ')'
|
||||||
self.query(sql)
|
self.query(sql)
|
||||||
for r in self.cursor.fetchall():
|
for r in self.cursor.fetchall():
|
||||||
print r[0]
|
print r[0]
|
||||||
|
|
||||||
|
# Name: retTicks
|
||||||
|
# Desc: Prints all samples for a given run
|
||||||
|
def retTicks(self, runs=None):
|
||||||
|
sql = 'select distinct dt_tick from data where dt_stat=1180 and ('
|
||||||
|
if runs != None:
|
||||||
|
first = True
|
||||||
|
for run in runs:
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
else:
|
||||||
|
sql += ' or'
|
||||||
|
sql += ' dt_run=%s' % run.run
|
||||||
|
sql += ')'
|
||||||
|
self.query(sql)
|
||||||
|
ret = []
|
||||||
|
for r in self.cursor.fetchall():
|
||||||
|
ret.append(r[0])
|
||||||
|
return ret
|
||||||
|
|
||||||
# Name: liststats
|
# Name: liststats
|
||||||
# Desc: Prints all statistics that appear in the database,
|
# Desc: Prints all statistics that appear in the database,
|
||||||
# the optional argument is a regular expression that can
|
# the optional argument is a regular expression that can
|
||||||
|
|
|
@ -249,6 +249,37 @@ def commands(options, command, args):
|
||||||
info.source.listRuns(user)
|
info.source.listRuns(user)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if command == 'stability':
|
||||||
|
stats = info.source.getStat(args[0])
|
||||||
|
info.source.get = "avg"
|
||||||
|
|
||||||
|
#loop through all the stats selected
|
||||||
|
for stat in stats:
|
||||||
|
avg = float(stat)
|
||||||
|
|
||||||
|
#loop through all the selected runs
|
||||||
|
for run in runs:
|
||||||
|
info.display_run = run.run;
|
||||||
|
#print run.name
|
||||||
|
#print avg
|
||||||
|
runTicks = info.source.retTicks([ run ])
|
||||||
|
#throw away the first one, it's 0
|
||||||
|
runTicks.pop(0)
|
||||||
|
|
||||||
|
#loop through all the various ticks for each run
|
||||||
|
for tick in runTicks:
|
||||||
|
stat.ticks = str(tick)
|
||||||
|
val = float(stat)
|
||||||
|
if (val < (avg * .9)) or (val > (avg * 1.1)):
|
||||||
|
print '%s:%s is %f, which is more than 10%% of the'\
|
||||||
|
'mean %f' % (run.name, stat.name, stat, avg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if command == 'stats':
|
if command == 'stats':
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
info.source.listStats()
|
info.source.listStats()
|
||||||
|
|
Loading…
Reference in a new issue