From 8cb2ee3f99cf64cb3bea74d2bb0fca9e5710594d Mon Sep 17 00:00:00 2001 From: Andrea Arteaga Date: Sat, 4 Aug 2012 22:23:44 +0200 Subject: Allow different image formats (defaults svg). Rewritten arguments parser. --- numbench/benchconfig.py | 28 ++++++++++++++++++++++------ numbench/main.py | 2 +- numbench/report.py | 9 +++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/numbench/benchconfig.py b/numbench/benchconfig.py index c0d8e8e..e7cc62a 100644 --- a/numbench/benchconfig.py +++ b/numbench/benchconfig.py @@ -44,20 +44,36 @@ if not locals().has_key('initialized'): libdir = 'usr/' + libdir # Parse arguments - passargs = sys.argv[3:] - for i,a in enumerate(passargs): + passargs = [] + skipargs = 0 + for i,a in enumerate(sys.argv[3:], 3): + if skipargs > 0: + skipargs -= 1 + continue + if a in ('-d', '--directory'): - basedir = pjoin(curdir, passargs[i+1]) - passargs = passargs[:i] + passargs[i+2:] - break + basedir = pjoin(curdir, sys.argv[i+1]) + skipargs += 1 + continue if a in ('-c', '--clean'): clean = True - passargs = passargs[:i] + passargs[i+1:] + continue + + if a in ('-i', '--imageformat'): + imageformat = sys.argv[i+1] + skipargs += 1 + continue + + passargs.append(a) # Clean flag if not locals().has_key('clean'): clean = False + + # Image format + if not locals().has_key('imageformat'): + imageformat = 'svg' # Storage directories if not locals().has_key('basedir'): diff --git a/numbench/main.py b/numbench/main.py index acfe6d7..bbd9b1f 100644 --- a/numbench/main.py +++ b/numbench/main.py @@ -106,7 +106,7 @@ if not os.path.exists(cfg.inputfile): cfg.tests = confinput.parseInput(cfg.inputfile) # Import the module -mod = loadModule(cfg.modulename).Module(sys.argv[3:]) +mod = loadModule(cfg.modulename).Module(cfg.passargs) cfg.mod = mod diff --git a/numbench/report.py b/numbench/report.py index 679aa54..5f834db 100644 --- a/numbench/report.py +++ b/numbench/report.py @@ -48,8 +48,8 @@ class Plotter: self.ylabel = conf.has_key('ylabel') and conf['ylabel'] or '' # Initialize markers - markers = ('-', '--', 'o', 'v', '^', 's', 'p', 'h', '*', '+', 'x', 'D') - colors = ('k', 'r', 'g', 'b') + markers = ('-', '--', 'v', '^', 'o', 's', 'p', 'h', '*', '+', 'x', 'D') + colors = ('k', 'r', 'g', 'b', 'c') self.linestyles = tuple([c+m for m in markers for c in colors]) self.curstyle = 0 @@ -67,7 +67,8 @@ class Plotter: plt.xlabel(self.xlabel) plt.ylabel(self.ylabel) plt.grid(True) - plt.savefig(fname, format='png', bbox_inches='tight', transparent=True) + plt.savefig(fname, format=cfg.imageformat, \ + bbox_inches='tight', transparent=True) @@ -104,7 +105,7 @@ def saveReport(): x,y = np.loadtxt(resultsFile, unpack=True) p.addPlot(x, y, tid+'/'+impl) - imgpath = pjoin('images', operation+'.png') + imgpath = pjoin('images', operation+'.'+cfg.imageformat) fname = pjoin(cfg.reportdir, imgpath) p.savePlot(fname) html.addFig(testdescr[operation], image=imgpath) -- cgit v1.2.3-65-gdbad