Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 235807 Details for
Bug 312915
[PATCH] media-libs/aubio-0.3.2-r1: Syntax errors with Python 2.6
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix for Python 2.6
aubio-0.3.2-python26.patch (text/plain), 11.61 KB, created by
Sebastian Pipping
on 2010-06-18 00:54:46 UTC
(
hide
)
Description:
Patch to fix for Python 2.6
Filename:
MIME Type:
Creator:
Sebastian Pipping
Created:
2010-06-18 00:54:46 UTC
Size:
11.61 KB
patch
obsolete
>From ae6ebaa7233329b11689939b102a9b5ec52579da Mon Sep 17 00:00:00 2001 >From: Sebastian Pipping <sebastian@pipping.org> >Date: Fri, 18 Jun 2010 02:33:06 +0200 >Subject: [PATCH] Introduce compatibility layer for Python 2.6 > >--- > python/aubio/bench/onset.py | 18 ++++++++++++------ > python/aubio/compat.py | 14 ++++++++++++++ > python/aubio/gnuplot.py | 6 ++++-- > python/aubio/plot/keyboard.py | 5 +++-- > python/aubio/task/beat.py | 6 ++++-- > python/aubio/task/notes.py | 12 +++++++----- > python/aubio/task/onset.py | 9 +++++---- > python/aubio/task/pitch.py | 6 ++++-- > 8 files changed, 53 insertions(+), 23 deletions(-) > create mode 100644 python/aubio/compat.py > >diff --git a/python/aubio/bench/onset.py b/python/aubio/bench/onset.py >index f9fbe23..4272620 100644 >--- a/python/aubio/bench/onset.py >+++ b/python/aubio/bench/onset.py >@@ -106,12 +106,13 @@ class benchonset(bench): > > def plotroc(self,d,plottitle=""): > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > gd = [] > fp = [] > for i in self.vlist: > gd.append(i['GD']) > fp.append(i['FP']) >- d.append(Gnuplot.Data(fp, gd, with='linespoints', >+ d.append(GnuplotData(fp, gd, with_='linespoints', > title="%s %s" % (plottitle,i['mode']) )) > > def plotplotroc(self,d,outplot=0,extension='ps'): >@@ -142,12 +143,13 @@ class benchonset(bench): > > def plotpr(self,d,plottitle=""): > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > x = [] > y = [] > for i in self.vlist: > x.append(i['prec']) > y.append(i['recl']) >- d.append(Gnuplot.Data(x, y, with='linespoints', >+ d.append(GnuplotData(x, y, with_='linespoints', > title="%s %s" % (plottitle,i['mode']) )) > > def plotplotpr(self,d,outplot=0,extension='ps'): >@@ -168,11 +170,12 @@ class benchonset(bench): > > def plotfmeas(self,d,plottitle=""): > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > x,y = [],[] > for i in self.vlist: > x.append(i['thres']) > y.append(i['dist']) >- d.append(Gnuplot.Data(x, y, with='linespoints', >+ d.append(GnuplotData(x, y, with_='linespoints', > title="%s %s" % (plottitle,i['mode']) )) > > def plotplotfmeas(self,d,outplot="",extension='ps', title="F-measure"): >@@ -201,11 +204,12 @@ class benchonset(bench): > > def plotfmeasvar(self,d,var,plottitle=""): > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > x,y = [],[] > for i in self.vlist: > x.append(i[var]) > y.append(i['dist']) >- d.append(Gnuplot.Data(x, y, with='linespoints', >+ d.append(GnuplotData(x, y, with_='linespoints', > title="%s %s" % (plottitle,i['mode']) )) > > def plotplotfmeasvar(self,d,var,outplot="",extension='ps', title="F-measure"): >@@ -228,6 +232,7 @@ class benchonset(bench): > > def plotdiffs(self,d,plottitle=""): > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > v = self.v > l = v['l'] > mean = v['mean'] >@@ -244,7 +249,7 @@ class benchonset(bench): > total = v['Torig'] > for i in range(len(per)): per[i] /= total/100. > >- d.append(Gnuplot.Data(val, per, with='fsteps', >+ d.append(GnuplotData(val, per, with_='fsteps', > title="%s %s" % (plottitle,v['mode']) )) > #d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean)) > #d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean)) >@@ -272,10 +277,11 @@ class benchonset(bench): > > def plothistcat(self,d,plottitle=""): > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > total = v['Torig'] > for i in range(len(per)): per[i] /= total/100. > >- d.append(Gnuplot.Data(val, per, with='fsteps', >+ d.append(GnuplotData(val, per, with_='fsteps', > title="%s %s" % (plottitle,v['mode']) )) > #d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean)) > #d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean)) >diff --git a/python/aubio/compat.py b/python/aubio/compat.py >new file mode 100644 >index 0000000..839507c >--- /dev/null >+++ b/python/aubio/compat.py >@@ -0,0 +1,14 @@ >+# -*- coding: utf-8 -*- >+# Copyright (C) 2010 Gentoo Foundation >+# Written by Sebastian Pipping <sebastian@pipping.org> >+# >+# Licensed under the same license as aubio 0.3.2 >+# >+import Gnuplot >+ >+def GnuplotData(*args, **kwargs): >+ """Wrapper for Python 2.6 compatibility >+ where "with" is a reserved keyword""" >+ kwargs['with'] = kwargs['_with'] >+ del kwargs['_with'] >+ return Gnuplot.Data(args, kwargs) >diff --git a/python/aubio/gnuplot.py b/python/aubio/gnuplot.py >index a01afeb..429e339 100644 >--- a/python/aubio/gnuplot.py >+++ b/python/aubio/gnuplot.py >@@ -154,18 +154,20 @@ def downsample_audio(time,data,maxpoints=10000): > def make_audio_plot(time,data,maxpoints=10000): > """ create gnuplot plot from an audio file """ > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > x,y = downsample_audio(time,data,maxpoints=maxpoints) >- return Gnuplot.Data(x,y,with='lines') >+ return GnuplotData(x,y,with_='lines') > > def make_audio_envelope(time,data,maxpoints=10000): > """ create gnuplot plot from an audio file """ > import numarray > import Gnuplot, Gnuplot.funcutils >+ from aubio.compat import GnuplotData > bufsize = 500 > x = [i.mean() for i in numarray.array(time).resize(len(time)/bufsize,bufsize)] > y = [i.mean() for i in numarray.array(data).resize(len(time)/bufsize,bufsize)] > x,y = downsample_audio(x,y,maxpoints=maxpoints) >- return Gnuplot.Data(x,y,with='lines') >+ return GnuplotData(x,y,with_='lines') > > def gnuplot_addargs(parser): > """ add common gnuplot argument to OptParser object """ >diff --git a/python/aubio/plot/keyboard.py b/python/aubio/plot/keyboard.py >index 8fe57d9..f2a8838 100755 >--- a/python/aubio/plot/keyboard.py >+++ b/python/aubio/plot/keyboard.py >@@ -1,6 +1,7 @@ > > def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1): > import Gnuplot >+ from aubio.compat import GnuplotData > octaves = 10 > > # build template of white notes >@@ -30,8 +31,8 @@ def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1): > yb = [y0+(y1-y0)*2/3. for i in range(len(xb))] > ybdelta = [(y1-y0)*1/3. for i in range(len(xb))] > >- whites = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with = 'boxxyerrorbars') >- blacks = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with = 'boxxyerrorbars fill solid') >+ whites = GnuplotData(xw,yw,xwdelta,ywdelta,with_='boxxyerrorbars') >+ blacks = GnuplotData(xb,yb,xbdelta,ybdelta,with_='boxxyerrorbars fill solid') > > return blacks,whites > >diff --git a/python/aubio/task/beat.py b/python/aubio/task/beat.py >index cc25250..010a08c 100644 >--- a/python/aubio/task/beat.py >+++ b/python/aubio/task/beat.py >@@ -247,16 +247,18 @@ class taskbeat(taskonset): > > def plot(self,oplots,results): > import Gnuplot >- oplots.append(Gnuplot.Data(results,with='linespoints',title="auto")) >+ from aubio.compat import GnuplotData >+ oplots.append(GnuplotData(results,with_='linespoints',title="auto")) > > def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False): > import Gnuplot > from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot > import re >+ from aubio.compat import GnuplotData > # audio data > #time,data = audio_to_array(self.input) > #f = make_audio_plot(time,data) > > g = gnuplot_create(outplot=outplot, extension=extension) >- oplots = [Gnuplot.Data(self.gettruth(),with='linespoints',title="orig")] + oplots >+ oplots = [GnuplotData(self.gettruth(),with_='linespoints',title="orig")] + oplots > g.plot(*oplots) >diff --git a/python/aubio/task/notes.py b/python/aubio/task/notes.py >index a729f94..802409a 100644 >--- a/python/aubio/task/notes.py >+++ b/python/aubio/task/notes.py >@@ -94,22 +94,24 @@ class tasknotes(task): > def plot(self,now,onset,freq,ifreq,oplots): > import numarray > import Gnuplot >+ from aubio.compat import GnuplotData > >- oplots.append(Gnuplot.Data(now,freq,with='lines', >+ oplots.append(GnuplotData(now,freq,with_='lines', > title=self.params.pitchmode)) >- oplots.append(Gnuplot.Data(now,ifreq,with='lines', >+ oplots.append(GnuplotData(now,ifreq,with_='lines', > title=self.params.pitchmode)) > > temponsets = [] > for i in onset: > temponsets.append(i*1000) >- oplots.append(Gnuplot.Data(now,temponsets,with='impulses', >+ oplots.append(GnuplotData(now,temponsets,with_='impulses', > title=self.params.pitchmode)) > > def plotplot(self,wplot,oplots,outplot=None,multiplot = 0): > from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot > import re > import Gnuplot >+ from aubio.compat import GnuplotData > # audio data > time,data = audio_to_array(self.input) > f = make_audio_plot(time,data) >@@ -117,10 +119,10 @@ class tasknotes(task): > # check if ground truth exists > #timet,pitcht = self.gettruth() > #if timet and pitcht: >- # oplots = [Gnuplot.Data(timet,pitcht,with='lines', >+ # oplots = [GnuplotData(timet,pitcht,with_='lines', > # title='ground truth')] + oplots > >- t = Gnuplot.Data(0,0,with='impulses') >+ t = GnuplotData(0,0,with_='impulses') > > g = gnuplot_init(outplot) > g('set title \'%s\'' % (re.sub('.*/','',self.input))) >diff --git a/python/aubio/task/onset.py b/python/aubio/task/onset.py >index 20a1282..1e573eb 100644 >--- a/python/aubio/task/onset.py >+++ b/python/aubio/task/onset.py >@@ -94,6 +94,7 @@ class taskonset(task): > import os.path > import numarray > from aubio.onsetcompare import onset_roc >+ from aubio.compat import GnuplotData > > x1,y1,y1p = [],[],[] > oplot = [] >@@ -103,7 +104,7 @@ class taskonset(task): > self.maxofunc = max(ofunc) > # onset detection function > downtime = numarray.arange(len(ofunc))*self.params.step >- oplot.append(Gnuplot.Data(downtime,ofunc,with='lines',title=self.params.onsetmode)) >+ oplot.append(GnuplotData(downtime,ofunc,with_='lines',title=self.params.onsetmode)) > > # detected onsets > if not nplot: >@@ -114,8 +115,8 @@ class taskonset(task): > #x1 = numarray.array(onsets)*self.params.step > #y1 = self.maxofunc*numarray.ones(len(onsets)) > if x1: >- oplot.append(Gnuplot.Data(x1,y1,with='impulses')) >- wplot.append(Gnuplot.Data(x1,y1p,with='impulses')) >+ oplot.append(GnuplotData(x1,y1,with_='impulses')) >+ wplot.append(GnuplotData(x1,y1p,with_='impulses')) > > oplots.append((oplot,self.params.onsetmode,self.maxofunc)) > >@@ -128,7 +129,7 @@ class taskonset(task): > t_onsets = aubio.txtfile.read_datafile(datafile) > x2 = numarray.array(t_onsets).resize(len(t_onsets)) > y2 = self.maxofunc*numarray.ones(len(t_onsets)) >- wplot.append(Gnuplot.Data(x2,y2,with='impulses')) >+ wplot.append(GnuplotData(x2,y2,with_='impulses')) > > tol = 0.050 > >diff --git a/python/aubio/task/pitch.py b/python/aubio/task/pitch.py >index d8ea1e2..3a6c03f 100644 >--- a/python/aubio/task/pitch.py >+++ b/python/aubio/task/pitch.py >@@ -153,10 +153,11 @@ class taskpitch(task): > > def plot(self,pitch,wplot,oplots,titles,outplot=None): > import Gnuplot >+ from aubio.compat import GnuplotData > > time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ] > pitch = [aubio_freqtomidi(i) for i in pitch] >- oplots.append(Gnuplot.Data(time,pitch,with='lines', >+ oplots.append(GnuplotData(time,pitch,with_='lines', > title=self.params.pitchmode)) > titles.append(self.params.pitchmode) > >@@ -165,12 +166,13 @@ class taskpitch(task): > from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot > import re > import Gnuplot >+ from aubio.compat import GnuplotData > > # check if ground truth exists > if truth: > timet,pitcht = self.gettruth() > if timet and pitcht: >- oplots = [Gnuplot.Data(timet,pitcht,with='lines', >+ oplots = [GnuplotData(timet,pitcht,with_='lines', > title='ground truth')] + oplots > > g = gnuplot_create(outplot=outplot, extension=extension) >-- >1.7.0.1.61.gdc05d.dirty >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 312915
: 235807