From: <mh...@us...> - 2007-03-30 12:52:16
|
Revision: 299 http://svn.sourceforge.net/gnuplot-py/?rev=299&view=rev Author: mhagger Date: 2007-03-30 05:52:17 -0700 (Fri, 30 Mar 2007) Log Message: ----------- "with" will be a Python keyword starting in Python 2.6 (and Python 2.5 already emits warnings if "with" is used as an identifier. So... Do not use "with" as an identifier within Gnuplot.py (including the test and demo scripts). Rename the PlotItem "with" parameter to "with_". However, for backwards compatibility (and through the magic of Python varargs processing), accept "with" as an alternative spelling of this option. This version runs on my computer, but I only have Python 2.4 installed, so I can't really test it. Modified Paths: -------------- trunk/PlotItems.py trunk/demo.py trunk/test.py Modified: trunk/PlotItems.py =================================================================== --- trunk/PlotItems.py 2007-03-30 11:27:17 UTC (rev 298) +++ trunk/PlotItems.py 2007-03-30 12:52:17 UTC (rev 299) @@ -83,11 +83,12 @@ _option_list = { 'axes' : lambda self, axes: self.set_string_option( 'axes', axes, None, 'axes %s'), - 'with' : lambda self, with: self.set_string_option( - 'with', with, None, 'with %s'), + 'with' : lambda self, with_: self.set_string_option( + 'with', with_, None, 'with %s'), 'title' : lambda self, title: self.set_string_option( 'title', title, 'notitle', 'title "%s"'), } + _option_list['with_'] = _option_list['with'] # order in which options need to be passed to gnuplot: _option_sequence = [ @@ -101,8 +102,8 @@ Keyword options: - 'with=<string>' -- choose how item will be plotted, e.g., - with='points 3 3'. + 'with_=<string>' -- choose how item will be plotted, e.g., + with_='points 3 3'. 'title=<string>' -- set the title to be associated with the item in the plot legend. @@ -215,7 +216,7 @@ into gnuplot itself. The argument to the contructor is a string that should be a mathematical expression. Example:: - g.plot(Func('sin(x)', with='line 3')) + g.plot(Func('sin(x)', with_='line 3')) As shorthand, a string passed to the plot method of a Gnuplot object is also treated as a Func:: Modified: trunk/demo.py =================================================================== --- trunk/demo.py 2007-03-30 11:27:17 UTC (rev 298) +++ trunk/demo.py 2007-03-30 12:52:17 UTC (rev 299) @@ -44,7 +44,7 @@ # written to a temporary file once. d = Gnuplot.Data(x, y1, title='calculated by python', - with='points 3 3') + with_='points 3 3') g.title('Data can be computed by python or gnuplot') g.xlabel('x') g.ylabel('x squared') Modified: trunk/test.py =================================================================== --- trunk/test.py 2007-03-30 11:27:17 UTC (rev 298) +++ trunk/test.py 2007-03-30 12:52:17 UTC (rev 299) @@ -73,7 +73,7 @@ g.replot() wait('Style linespoints') - g.plot(Gnuplot.Func('sin(x)', with='linespoints')) + g.plot(Gnuplot.Func('sin(x)', with_='linespoints')) wait('title=None') g.plot(Gnuplot.Func('sin(x)', title=None)) wait('title="Sine of x"') @@ -86,7 +86,7 @@ wait('Original') g.plot(f) wait('Style linespoints') - f.set_option(with='linespoints') + f.set_option(with_='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) @@ -103,20 +103,20 @@ g.plot(Gnuplot.File(filename1)) wait('Style lines') - g.plot(Gnuplot.File(filename1, with='lines')) + g.plot(Gnuplot.File(filename1, with_='lines')) wait('using=1, using=(1,)') - g.plot(Gnuplot.File(filename1, using=1, with='lines'), - Gnuplot.File(filename1, using=(1,), with='points')) + g.plot(Gnuplot.File(filename1, using=1, with_='lines'), + Gnuplot.File(filename1, using=(1,), with_='points')) wait('using=(1,2), using="1:3"') g.plot(Gnuplot.File(filename1, using=(1,2)), Gnuplot.File(filename1, using='1:3')) wait('every=5, every=(5,)') - g.plot(Gnuplot.File(filename1, every=5, with='lines'), - Gnuplot.File(filename1, every=(5,), with='points')) + g.plot(Gnuplot.File(filename1, every=5, with_='lines'), + Gnuplot.File(filename1, every=(5,), with_='points')) wait('every=(10,None,0), every="10::5"') - g.plot(Gnuplot.File(filename1, with='lines'), + g.plot(Gnuplot.File(filename1, with_='lines'), Gnuplot.File(filename1, every=(10,None,0)), Gnuplot.File(filename1, every='10::5')) @@ -130,7 +130,7 @@ wait('Original') g.plot(f) wait('Style linespoints') - f.set_option(with='linespoints') + f.set_option(with_='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) @@ -163,8 +163,8 @@ g.plot(Gnuplot.File(filename1)) wait('Same thing, inline data') g.plot(Gnuplot.Data(d, inline=1)) - wait('with="lp 4 4"') - g.plot(Gnuplot.Data(d, with='lp 4 4')) + wait('with_="lp 4 4"') + g.plot(Gnuplot.Data(d, with_='lp 4 4')) wait('cols=0') g.plot(Gnuplot.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') @@ -199,13 +199,13 @@ g.plot(Gnuplot.File(filename1)) wait('Same thing, inline data') g.plot(Gnuplot.funcutils.compute_Data(x, math.cos, inline=1)) - wait('with="lp 4 4"') - g.plot(Gnuplot.funcutils.compute_Data(x, math.cos, with='lp 4 4')) + wait('with_="lp 4 4"') + g.plot(Gnuplot.funcutils.compute_Data(x, math.cos, with_='lp 4 4')) print '############### test hardcopy ###############################' print '******** Generating postscript file "gp_test.ps" ********' wait() - g.plot(Gnuplot.Func('cos(0.5*x*x)', with='linespoints 2 2', + g.plot(Gnuplot.Func('cos(0.5*x*x)', with_='linespoints 2 2', title='cos(0.5*x^2)')) g.hardcopy('gp_test.ps') @@ -249,12 +249,12 @@ print '############### test splot ##################################' wait('a 3-d curve') - g.splot(Gnuplot.Data(d, with='linesp', inline=0)) + g.splot(Gnuplot.Data(d, with_='linesp', inline=0)) wait('Same thing, saved to a file') Gnuplot.Data(d, inline=0, filename=filename1) - g.splot(Gnuplot.File(filename1, with='linesp')) + g.splot(Gnuplot.File(filename1, with_='linesp')) wait('Same thing, inline data') - g.splot(Gnuplot.Data(d, with='linesp', inline=1)) + g.splot(Gnuplot.Data(d, with_='linesp', inline=1)) print '############### test GridData and compute_GridData ##########' # set up x and y values at which the function will be tabulated: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |