From 336cf77a8d4d2a227543fcf6ba8e3cbd92161ab1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 16 Dec 2005 04:34:00 +0000 Subject: [PATCH] rename class task to bench, move pretty_print into it rename class task to bench, move pretty_print into it --- python/aubio/bench/node.py | 15 ++++++++++++--- python/bench-onset | 19 +++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/python/aubio/bench/node.py b/python/aubio/bench/node.py index c5b37152..efb3e005 100644 --- a/python/aubio/bench/node.py +++ b/python/aubio/bench/node.py @@ -70,14 +70,15 @@ def act_on_results (action,datapath,respath,filter='d'): s = re.split(datapath, i ,maxsplit=1)[1] action("%s%s%s"%(respath,'/',s)) -class task: +class bench: - def __init__(self,datadir,resdir): + def __init__(self,datadir,resdir,checkres=False,checkanno=False): self.datadir = datadir self.resdir = resdir print "Checking data directory", self.datadir self.checkdata() - self.checkres() + if checkanno: self.checkanno() + if checkres: self.checkres() def checkdata(self): print "Listing directories in data directory", @@ -88,6 +89,8 @@ class task: self.sndlist = list_snd_files(self.datadir) print " (%d elements)" % len(self.sndlist) #for each in self.sndlist: print each + + def checkanno(self): print "Listing annotations in data directory", self.reslist = list_res_files(self.datadir) print " (%d elements)" % len(self.reslist) @@ -101,3 +104,9 @@ class task: def checkres(self): print "Creating results directory" act_on_results(mkdir,self.datadir,self.resdir,filter='d') + + def pretty_print(self,values): + for i in range(len(values)): + print self.formats[i] % values[i], + print + diff --git a/python/bench-onset b/python/bench-onset index 9287e617..a02a2b9d 100755 --- a/python/bench-onset +++ b/python/bench-onset @@ -17,13 +17,8 @@ class onset_parameters: self.threshold = 0.1 self.mode = 'dual' -class taskonset(task): +class benchonset(bench): - def pretty_print(self,values): - for i in range(len(values)): - print self.formats[i] % values[i], - print - def compute_results(self): self.P = 100*float(self.expc-self.missed-self.merged)/(self.expc-self.missed-self.merged + self.bad+self.doubled) self.R = 100*float(self.expc-self.missed-self.merged)/(self.expc-self.missed-self.merged + self.missed+self.merged) @@ -157,19 +152,19 @@ thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5] datapath = "%s%s" % (DATADIR,'/onset/DB/PercussivePhrases/RobertRich') respath = '/var/tmp/DB-testings' -taskonset = taskonset(datapath,respath) +benchonset = benchonset(datapath,respath,checkres=True,checkanno=True) -taskonset.params = onset_parameters() +benchonset.params = onset_parameters() -taskonset.titles = [ 'mode', 'thres', 'orig', 'expc', 'missd', 'mergd', +benchonset.titles = [ 'mode', 'thres', 'orig', 'expc', 'missd', 'mergd', 'bad', 'doubl', 'corrt', 'GD', 'FP', 'GD-merged', 'FP-pruned', 'prec', 'recl', 'dist' ] -taskonset.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", +benchonset.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", "| %8s", "| %8s", "| %8s", "| %8s", "| %6s", "| %6s", "| %6s"] -#taskonset.run_bench(modes=modes,thresholds=thresholds) -taskonset.auto_learn(modes=modes) +#benchonset.run_bench(modes=modes,thresholds=thresholds) +benchonset.auto_learn(modes=modes) # gatherdata #act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') -- 2.26.2