25a26,27
> #
> # Authors: Nathan Binkert
137a140,143
> self.allBins = []
> self.allBinIds = {}
> self.allBinNames = {}
>
145a152
> self.bins = None
215a223,227
> self.query('select * from bins')
> for id,name in self.cursor.fetchall():
> self.allBinIds[int(id)] = name
> self.allBinNames[name] = int(id)
>
237a250,261
> # 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)
>
340a365,393
> 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
>
344c397
< def query(self, op, stat, ticks, group=False):
---
> def inner(self, op, stat, bins, ticks, group=False):
365a419,422
> if bins != None and len(bins):
> val = ' or '.join([ 'dt_bin=%d' % b for b in bins ])
> sql += ' and (%s)' % val
>
374a432,437
> 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
>
376,378c439,444
< # 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)
---
> # 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)
381,383c447,452
< # 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)
---
> # 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)
386,389c455,460
< # 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)
---
> # 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)
405c476,478
< def data(self, stat, ticks=None):
---
> def data(self, stat, bins=None, ticks=None):
> if bins is None:
> bins = self.bins
408c481
< sql = self._method(self, stat, ticks)
---
> sql = self._method(self, stat, bins, ticks)