shithub: aubio

Download patch

ref: 336cf77a8d4d2a227543fcf6ba8e3cbd92161ab1
parent: 75139a99ef6ddaba3713d9a1181659c8026d02a3
author: Paul Brossier <piem@altern.org>
date: Thu Dec 15 23:34:00 EST 2005

rename class task to bench, move pretty_print into it
rename class task to bench, move pretty_print into it


--- a/python/aubio/bench/node.py
+++ b/python/aubio/bench/node.py
@@ -70,14 +70,15 @@
                 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 @@
 		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 @@
 	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
+
--- a/python/bench-onset
+++ b/python/bench-onset
@@ -17,13 +17,8 @@
 		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 @@
 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\'')