140,143d139
< self.allBins = []
< self.allBinIds = {}
< self.allBinNames = {}
<
152d147
< self.bins = None
223,227d217
< self.query('select * from bins')
< for id,name in self.cursor.fetchall():
< self.allBinIds[int(id)] = name
< self.allBinNames[name] = int(id)
<
250,261d239
< # Name: listbins
< # Desc: Prints all bins matching regex argument, if no argument
< # is given all bins are returned
< def listBins(self, regex='.*'):
< print '%-50s %-10s' % ('bin name', 'id')
< print '-' * 61
< names = self.allBinNames.keys()
< names.sort()
< for name in names:
< id = self.allBinNames[name]
< print '%-50s %-10d' % (name, id)
<
365,393d342
< def getBin(self, bins):
< if type(bins) is not list:
< bins = [ bins ]
<
< ret = []
< for bin in bins:
< if type(bin) is int:
< ret.append(bin)
< elif type(bin) is str:
< ret.append(self.allBinNames[bin])
< else:
< for name,id in self.allBinNames.items():
< if bin.match(name):
< ret.append(id)
<
< return ret
<
< def getNotBin(self, bin):
< map = {}
< for bin in getBin(bin):
< map[bin] = 1
<
< ret = []
< for bin in self.allBinIds.keys():
< if not map.has_key(bin):
< ret.append(bin)
<
< return ret
<
397c346
< def inner(self, op, stat, bins, ticks, group=False):
---
> def query(self, op, stat, ticks, group=False):
419,422d367
< if bins != None and len(bins):
< val = ' or '.join([ 'dt_bin=%d' % b for b in bins ])
< sql += ' and (%s)' % val
<
432,437d376
< def outer(self, op_out, op_in, stat, bins, ticks):
< sql = self.inner(op_in, stat, bins, ticks, True)
< sql = 'select stat,run,x,y,%s(data) from (%s) as tb ' % (op_out, sql)
< sql += 'group by stat,run,x,y'
< return sql
<
439,444c378,380
< # Desc: given a run, a stat and an array of samples and bins,
< # sum all the bins and then get the standard deviation of the
< # samples for non-binned runs. This will just return the average
< # of samples, however a bin array still must be passed
< def sum(self, stat, bins, ticks):
< return self.inner('sum', stat, bins, ticks)
---
> # Desc: given a run, a stat and an array of samples, total the samples
> def sum(self, *args, **kwargs):
> return self.query('sum', *args, **kwargs)
447,452c383,385
< # Desc: given a run, a stat and an array of samples and bins,
< # sum all the bins and then average the samples for non-binned
< # runs this will just return the average of samples, however
< # a bin array still must be passed
< def avg(self, stat, bins, ticks):
< return self.outer('avg', 'sum', stat, bins, ticks)
---
> # Desc: given a run, a stat and an array of samples, average the samples
> def avg(self, stat, ticks):
> return self.query('avg', *args, **kwargs)
455,460c388,391
< # Desc: given a run, a stat and an array of samples and bins,
< # sum all the bins and then get the standard deviation of the
< # samples for non-binned runs. This will just return the average
< # of samples, however a bin array still must be passed
< def stdev(self, stat, bins, ticks):
< return self.outer('stddev', 'sum', stat, bins, ticks)
---
> # Desc: given a run, a stat and an array of samples, get the standard
> # deviation
> def stdev(self, stat, ticks):
> return self.query('stddev', *args, **kwargs)
476,478c407
< def data(self, stat, bins=None, ticks=None):
< if bins is None:
< bins = self.bins
---
> def data(self, stat, ticks=None):
481c410
< sql = self._method(self, stat, bins, ticks)
---
> sql = self._method(self, stat, ticks)