Plot pkg - Multiple Y axes?
Hello, I'm searching for a plotting package that will allow multiple y axes of different scales. For example I'd like to overlay 4 or 5 time series with each series having a separate axis. Does anyone know of such a package? Thank you, Frank -- http://mail.python.org/mailman/listinfo/python-list
Execution time of lines within a function
Hello, I have a function that hotshot says is very slow. I can get the aggregate execution time, but is there a way to get the execution time of each line so I can find the bottleneck? Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Execution time of lines within a function
Thanks Neil, I looked at that, but maybe I don't understand the output. I was hoping to see the cummulative time for the function and then the time associated with each statement (line) within the function. In the hotshot output below, I can see the function being called 100 times, which is correct, but the rest seems at too low a level for me to understand which statements are causing the slow execution. Any suggestions? hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865 hw6r3.py:126(findphi)(100) 6153.585 hw6r3.py:173(findu)(100) 1823.852 hw6r3.py:197(findv)(100) 2392.977 numeric.py:31(zeros_like)(3) 0.072 numeric.py:286(array_str)(1) 0.677 rpc.py:545(__getattr__)(13) 0.197 rpc.py:589(__call__)(12) 51.334 rpc.py:319(putmessage) :1(fileno)(12)0.039 rpc.py:149(debug)(12)0.126 rpc.py:236(asyncreturn) rpc.py:149(debug)(24)0.126 rpc.py:242(decoderesponse)(12) 0.015 rpc.py:277(getresponse)(12) 48.166 Regards, Frank Neil Cerutti wrote: > On 2006-12-04, monkeyboy <[EMAIL PROTECTED]> wrote: > > I have a function that hotshot says is very slow. I can get the > > aggregate execution time, but is there a way to get the > > execution time of each line so I can find the bottleneck? > > Try 'print_callees' on the stats object for your bottleneck. That > may help. > > -- > Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Execution time of lines within a function
The output was from print_callees(). It appears as though print_stats() and print_callees() return the same data, just in a different orangization. There is supposed to be a "lineevents=1" option in hotshot.Profile, for line timings, but it doesn't seem to work in Python 2.4. Thanks for your help Neil Cerutti wrote: > On 2006-12-04, monkeyboy <[EMAIL PROTECTED]> wrote: > > Thanks Neil, > > > > I looked at that, but maybe I don't understand the output. I > > was hoping to see the cummulative time for the function and > > then the time associated with each statement (line) within the > > function. > > > > Any suggestions? > > I don't think the Python Profiler goes down to that level. The > next step might be to analyze the function yourself and try to > understand why it is so slow. Post the code here and let the > readers pick it apart. > > > In the hotshot output below, I can see the function being > > called 100 times, which is correct, but the rest seems at too > > low a level for me to understand which statements are causing > > the slow execution. > > > > > > hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865 > > Is this the print_callees output? > > -- > Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Help with weave.blitz()
Hello, I'm a new scipy user, and I'm trying to speed up some array code with weave. I'm running xp with gcc from cgywin, and scipy.weave.test() returns an OK status. I'm trying to speed up the code below. I've found a couple of examples of weave on the web, and I think it should be straight forward, but I keep getting the following error when calling weave.blitz(expr). It's complaining about the variable being assigned, I've tried listing it in the blitz call with no luck. Any help is appreciated. PS I've also posted to scipy.org Thank you, Frank ***ERROR*** Traceback (most recent call last): File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeWeave.py", line 436, in -toplevel- prof.runcall(main) File "C:\Python24\Lib\hotshot\__init__.py", line 76, in runcall return self._prof.runcall(func, args, kw) File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeWeave.py", line 383, in main findw(w,wprior,phiprior,uprior,vprior) File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeWeave.py", line 136, in findw weave.blitz(expr) File "C:\Python24\Lib\site-packages\scipy\weave\blitz_tools.py", line 35, in blitz if check_size and not size_check.check_expr(expr,local_dict,global_dict): File "C:\Python24\Lib\site-packages\scipy\weave\size_check.py", line 51, in check_expr exec(expr,values) File "", line 1 wnext[1:grows-1,1:gcols-1] =( alpha * w[1:grows-1,1:gcols-1] + ax * (w[1:grows-1,0:gcols-2] + w[1:grows-1,2:gcols]) + ^ SyntaxError: invalid syntax ***CODE*** def findw(wnext,wprior,phiprior,uprior,vprior): #format here is x[i,j] where i's are rows, j's columns, use flipud() to get the #print out consistent with the spacial up-down directions #assign local names that are more #inline with the class notation w = wprior phi = phiprior u = uprior v = vprior #three of the BC are known so just set them #symetry plane wnext[0,0:gcols] = 0.0 #upper wall wnext[gN,0:gcols] = 2.0/gdy**2 * (phi[gN,0:gcols] - phi[gN-1,0:gcols]) #inlet, off the walls wnext[1:grows-1,0] = 0.0 upos = where(u>0) vpos = where(v>0) Sx = ones_like(u) Sx[upos] = 0.0 xSx = 1.0 - Sx Sy = ones_like(v) Sy[vpos] = 0.0 ySy = 1.0 - Sy uw = u*w vw = v*w ax = gnu*gdt/gdx**2 ay = gnu*gdt/gdy**2 dtdx = gdt/gdx dtdy = gdt/gdy alpha = (1.0 - 2.0*ax - 2.0*ay) #interior nodes expr = """ \ wnext[1:grows-1,1:gcols-1] =( alpha * w[1:grows-1,1:gcols-1] + ax * (w[1:grows-1,0:gcols-2] + w[1:grows-1,2:gcols]) + ay * (w[0:grows-2,1:gcols-1] + w[2:grows,1:gcols-1]) - dtdx * (xSx[1:grows-1,1:gcols-1] * (uw[1:grows-1,1:gcols-1] - uw[1:grows-1,0:gcols-2]) - Sx[1:grows-1,1:gcols-1] * (uw[1:grows-1,2:gcols] - uw[1:grows-1,1:gcols-1])) - dtdy * (ySy[1:grows-1,1:gcols-1] * (vw[1:grows-1,1:gcols-1] - vw[1:grows-1,0:gcols-2]) - Sy[1:grows-1,1:gcols-1] * (vw[1:grows-1,2:gcols] - vw[1:grows-1,1:gcols-1])) ) """ #weave.inline(expr,['wnext','w','Sx','xSx','Sy','ySy','uw','vw','ax','ay','dtdx','dtdy','alpha','grows','gcols']) #weave.inline(expr,['wnext'],compiler='gcc',verbose=2) #weave.blitz(expr,['wnext','w','Sx','xSx','Sy','ySy','uw','vw','ax','ay','dtdx','dtdy','alpha','grows','gcols']) #weave.blitz(expr,size_check=1) #weave.inline(expr,['wnext']) weave.blitz(expr) ##for j in range(1,gasizej-1): ##for i in range(1,gasizei-1): ## ##wnext[i,j] =( w[i,j] + gnu*gdt/gdx**2 * (w[i,j-1] - 2.0*w[i,j] + w[i,j+1]) + ## gnu*gdt/gdy**2 * (w[i-1,j] - 2.0*w[i,j] + w[i+1,j]) - ## (1.0 - Sx[i,j]) * gdt/gdx * (uw[i,j] - uw[i,j-1]) - ## Sx[i,j] * gdt/gdx * (uw[i,j+1] - uw[i,j]) - ## (1.0 - Sy[i,j]) * gdt/gdy * (vw[i,j] - vw[i-1,j]) - ## Sy[i,j] * gdt/gdy * (vw[i+1,j] - vw[i,j]) ) ##print "***wnext" ##print "i: ", i, "j: ", j, "wnext[i,j]: ", wnext[i,j] #final BC at outlet, off walls wnext[1:grows-1,gM] = wnext[1:grows-1,gM-1] -- http://mail.python.org/mailman/listinfo/python-list
Simple Class/Variable passing question
Hello, I'm new to python, and PythonCard. In the code below, I'm trying to create a member variable (self.currValue) of the class, then just pass it to a simple function (MainOutputRoutine) to increment it. I thought Python "passed by reference" all variables, but the member variable doesn't seem to be incremented. If I make the function just increment the member variable directly, without passing it in, it works fine? In the code below, "self.currValue" stays at 5, and value evaluates to 1? Any insight would be appreciated... class TestModel(model.Background): def on_initialize(self,event): self.currValue = 5 def on_startBtn_mouseClick(self, event): self.MainOutputRoutine(self.currValue) self.OutputRoutine(self.currValue) def OutputRoutine(self,value): self.components.txtBox1.text = str(value) def MainOutputRoutine(self,value): value = value + 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Class/Variable passing question
On Jun 19, 6:37 pm, Matt Nordhoff <[EMAIL PROTECTED]> wrote:
> monkeyboy wrote:
> > Hello,
>
> > I'm new to python, and PythonCard. In the code below, I'm trying to
> > create a member variable (self.currValue) of the class, then just pass
> > it to a simple function (MainOutputRoutine) to increment it. I thought
> > Python "passed by reference" all variables, but the member variable
> > doesn't seem to be incremented. If I make the function just increment
> > the member variable directly, without passing it in, it works fine?
>
> > In the code below, "self.currValue" stays at 5, and value evaluates to
> > 1? Any insight would be appreciated...
>
> > class TestModel(model.Background):
>
> > def on_initialize(self,event):
> > self.currValue = 5
>
> > def on_startBtn_mouseClick(self, event):
> > self.MainOutputRoutine(self.currValue)
> > self.OutputRoutine(self.currValue)
>
> > def OutputRoutine(self,value):
> > self.components.txtBox1.text = str(value)
>
> > def MainOutputRoutine(self,value):
> > value = value + 1
>
> That's not how Python works. When you call
> "self.MainOutputRoutine(self.currValue)", in that method's scope, the
> local name "value" points to the same object as self.currValue does.
> When you do "value = value + 1", the local name "value" now points to a
> different object. That has no bearing on self.currValue.
>
> Err, I can't find a guide here. Um, read the language spec? I dunno.
>
> However:
>
> >>> my_list = [1]
> >>> def function(l):
> ... l.append(2)
> >>> function(my_list)
> >>> my_list
>
> [1, 2]
>
> That's because function() is *mutating* the list; it's not changing what
> the "l" name points to. It's calling the "append" method of the list
> object, which changes said list object. If it were doing, say, "l = 42",
> that would only rebind the function's local name "l":
>
> >>> my_list = [1]
> >>> def function(l):
> ... l = 42
> >>> function(my_list)
> >>> my_list
>
> [1]
>
> Note that strings and integers are immutable, so whenever you think
> you're mutating them (e.g. "s.replace('a', 'b')" or "i += 1"), you're
> actually getting a whole new, different object, with all that that implies.
> --
Thank you, I haven't used python for a couple of years, and I didn't
recall that aspect of the language. I'll have to dig out my O'Reilly
book,
--
http://mail.python.org/mailman/listinfo/python-list
Question on class module import
Hello,
I want to write a wrapper class around a windows dll. If I put the
class in a module "Refprop.py" then import the class where I want to
use it, does the whole module get read by the interpreter or just the
class code?...
For example if I say the following in "Refprop.py" does the code above
the class statement get run on an import or should the loadLibrary
call be made in the constructor...the code below appears to work OK, I
just want to be sure I understand what happens on an import call
from ctypes import *
rp = windll.LoadLibrary("refprop.dll")
class refprop():
'''
REFPORP class
'''
nc = c_long(1)
ierr = c_long(0)
..
--
http://mail.python.org/mailman/listinfo/python-list
Re: Question on class module import
Thank you, that clears it for me -- http://mail.python.org/mailman/listinfo/python-list
