From: Rich S. <rsh...@ap...> - 2008-03-31 18:03:23
|
Thanks to Joerg I fixed my inability to call curve-generating functions in a separate module. Now I'm getting an error when trying to use the returned values, and I don't see in the source code how to do this correctly. The module with the curve plotting functions writes the results to the application's 'config.py' module that is used to share values among different modules. For example, this function, def gaussCurve(midpt, width): center = midpt fwhm = width x = nx.arange(0, 100, 0.1) G = gauss1d(x, fwhm, center) appData.plotX = x appData.plotY = G works as intended. In the calling function I try to use these values, but get the error message that g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY) AttributeError: values instance has no attribute '__getitem__' Just before the call to g.plot() I can print these two lists (e.g, print appData.plotX) successfully. I've tried using using the lists directly g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY) [graph.style.line([style.linewidth.Thin])]) and indirectly x = config.appData.plotX y = config.appData.plotY g.plot(graph.data.values(x=x, y=y) [graph.style.line([style.linewidth.Thin])]) but I get the same error. Is it obvious what I've missed? Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863 |
From: Alan G I. <ai...@am...> - 2008-03-31 18:32:43
|
On Mon, 31 Mar 2008, Rich Shepard apparently wrote: > Is it obvious what I've missed? A comma ... ? Cheers, Alan Isaac |
From: Rich S. <rsh...@ap...> - 2008-03-31 19:11:17
|
On Mon, 31 Mar 2008, Alan G Isaac wrote: > A comma ... ? Alan, The x and y values produced by the curve function are each a list of values, space separated. When plotted in the same module there is no error. I see in the on-line docs that spaces are used to separate x and y values in the example data <http://pyx.sourceforge.net/manual/node31.html>. Reading the next section (4.2), I see that the 'graph' component "Keeps lists of plotted data, ...". But, I have no data directives in the graph.graphxy() function. At the head of the calling function I set up axes, painters, texter, then call graph.graphxy(). Then I go through the input data and call the appropriate curve generating function. When that returns I call plot(graph.data.values()) Where might I have a missing comma? Thanks, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863 |
From: Alan G I. <ai...@am...> - 2008-03-31 19:29:54
|
On Mon, 31 Mar 2008, Rich Shepard apparently wrote: > plot(graph.data.values()) But that is not the example you posted, where values was followed by a list without a separating comma. (Assuming you copied and pasted.) Cheers, Alan Isaac |
From: Rich S. <rsh...@ap...> - 2008-03-31 20:44:52
|
On Mon, 31 Mar 2008, Alan G Isaac wrote: > But that is not the example you posted, where values was followed by a > list without a separating comma. (Assuming you copied and pasted.) Alan, Sorry to seem so dense, but I don't see a list without a separating comma. My original message had g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY) [graph.style.line([style.linewidth.Thin])]) and x = config.appData.plotX y = config.appData.plotY g.plot(graph.data.values(x=x, y=y) [graph.style.line([style.linewidth.Thin])]) When I run the code via winpdb at the bottom, when testCode() is called, the debugger jumps to the exception reporting. I never see the values at the line that threw that exception. Pointers to how to debug this code, or how to call the plot() module are appreciated. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863 |
From: Alan G I. <ai...@am...> - 2008-03-31 21:18:24
|
On Mon, 31 Mar 2008, Rich Shepard apparently wrote: > g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY) [graph.style.line([style.linewidth.Thin])]) ^ That's why you get that error message: it the brackets are calling getitem. Cheers, Alan |
From: Tim H. <be...@gm...> - 2008-03-31 21:18:24
|
Hello, On 31/03/2008, Rich Shepard <rsh...@ap...> wrote: > On Mon, 31 Mar 2008, Alan G Isaac wrote: > > > But that is not the example you posted, where values was followed by a > > list without a separating comma. (Assuming you copied and pasted.) > > > Alan, > > Sorry to seem so dense, but I don't see a list without a separating comma. > > My original message had > > > g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY) > [graph.style.line([style.linewidth.Thin])]) > should be: g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY), [graph.style.line([style.linewidth.Thin])]) with all these dots and [ and ] it is sometimes hard to not loose track ... ;]] Though I am surprised python didn't cry "Syntax error". tim > and > > > x = config.appData.plotX > y = config.appData.plotY > > g.plot(graph.data.values(x=x, y=y) > [graph.style.line([style.linewidth.Thin])]) > > > When I run the code via winpdb at the bottom, when testCode() is called, > the debugger jumps to the exception reporting. I never see the values at the > line that threw that exception. > > Pointers to how to debug this code, or how to call the plot() module are > appreciated. > > > Rich > > -- > Richard B. Shepard, Ph.D. | Integrity Credibility > Applied Ecosystem Services, Inc. | Innovation > <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863 > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > PyX-user mailing list > PyX...@li... > https://lists.sourceforge.net/lists/listinfo/pyx-user > -- http://tim.jottit.com/ |
From: Rich S. <rsh...@ap...> - 2008-03-31 21:55:40
|
On Mon, 31 Mar 2008, Tim Head wrote: > g.plot(graph.data.values(x=config.appData.plotX, y=config.appData.plotY), ^ Aha! You're right, Tim. I never noticed the missing comma there. Many thanks! Now I need to figure out how to accumulate the curves that comprise one plot. But, I'm well on my way. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863 |