rename class task to bench, move pretty_print into it
authorPaul Brossier <piem@altern.org>
Fri, 16 Dec 2005 04:34:00 +0000 (04:34 +0000)
committerPaul Brossier <piem@altern.org>
Fri, 16 Dec 2005 04:34:00 +0000 (04:34 +0000)
rename class task to bench, move pretty_print into it

python/aubio/bench/node.py
python/bench-onset

index c5b3715..efb3e00 100644 (file)
@@ -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
+
index 9287e61..a02a2b9 100755 (executable)
@@ -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\'')