[Numpy-discussion] Profiling line-by-line
Is there any way to do line-by-line profiling in Python? The profiling results can tell me how much time is spent in all functions, but within a given function I can't get any idea of how much time was spent on each line. For example, in the example below, I can see that graphWidth.py is taking all the time, but there are many lines of code in graphWidth.py that aren't function calls, and I have no way of knowing which lines are the bottlenecks. I'm using hotspot currently, by the way. ncallstottimepercallcumtimepercall filename:lineno(function) 10.2150.2150.2210.221 graphWidth.py:6(graphWidth) 270.0010..0030.000 oldnumeric.py:472(all) 260.0020..0020.000 oldnumeric.py:410(sum) 260.0010..0020.000 oldnumeric.py:163(_wrapit) 260.0010..0010.000 oldnumeric.py:283(argmin) 260....000 numeric.py:111(asarray)00.000 0.000profile:0(profiler)Thanks,-- David Grant - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Pretty printing an array: no ellipses?
On Wed, Jul 19, 2006 at 03:06:00PM -0700, Webb Sprague wrote: I am not sure where to look for this, sorry if it is RTFM or JPS (just plain stupid): Is there a way to set a default to print the entire array, rather than an ellipses version of it? If not, why doesn't pprint.pformat(numpy.random.normal(0,1,(100, 100)), width=1000) at least give me something off the screen? Try N.set_printoptions(threshold=N.nan) Stéfan - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] vector to tensor matrix speed up
Hi users, i have some problem in Numpy with indexing speed for array to tensor matrix transport. With 20 cycles it's 9sec ! (without sort(eigvals() - functions) Many thanks f. # stress values/matrix in array form for 20 points out = zeros((20,11),Float32) # #.out = filling matrix ...etc... # # stress tensor matrix eig = zeros((3,3),Float32) # #output for eigvalues eigwert = array([0,0,0]) # for j in arange(0,20): eig[0,0] = out[j,1] eig[1,1] = out[j,2] eig[2,2] = out[j,3] # eig[0,1] = out[j,4] eig[0,2] = out[j,6] eig[1,0] = out[j,4] eig[1,2] = out[j,5] eig[2,0] = out[j,6] eig[2,1] = out[j,5] # eigwert = sort(eigvals(eig)) out[j,7] = eigwert[2] out[j,8] = eigwert[1] out[j,9] = eigwert[0] out[j,10] = abs(eigwert[0]-eigwert[2]) # - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] numpy.var and numpy.std
Are these functions supposed to compute variance and standard deviation? They don't have docstrings and I can't find anything about them in Travis' manual. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.var and numpy.std
Yes, In SVN, std has a docstring and I submitted one for var in ticket #174. David2006/7/20, Tom Denniston [EMAIL PROTECTED] :Are these functions supposed to compute variance and standarddeviation?They don't have docstrings and I can't find anything about them in Travis' manual.-Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cashhttp://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___Numpy-discussion mailing listNumpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.var and numpy.std
Tom Denniston wrote: Are these functions supposed to compute variance and standard deviation? They don't have docstrings and I can't find anything about them in Travis' manual. These are in the manual but only as a general reference to the fact that array methods also have functional counter-parts. In other words, a.meth() -- meth(a) The latter is more general because a does not have to be an array already. -Travis - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.var and numpy.std
Tom Denniston wrote: Are these functions supposed to compute variance and standard deviation? They don't have docstrings and I can't find anything about them in Travis' manual. I just wanted to advertise the fact that there are two utility functions in NumPy that can come in handy for people wanting to add docstrings to built-in types. These utility functions by-pass the need to fiddle with doc-strings in C-code (which can be a pain) and re-compile every time a doc-string is changed. These are meant to be run once They are: add_docstring(obj, string) Add a string as the docstring of obj. A wide-variety of builtin types are understood. If it doesn't know how to add it, you get a TypeError. If the object already has a doc-string you get a RuntimeError. add_newdoc(place, obj, doc) This is a wrapper around docstring to make it easier to add docs to many attributes of an object which is stored in place. It never fails. place and obj are both strings doc is a string, list, or tuple place is the module name obj is the object in that module If doc is a string add it to place.obj If doc is a tuple it is (attr, doc) --- the first element is the attribute of obj and the second is the docstring. If doc is a list it is [(attr1, doc1), (attr2, doc2), ...] -- the elements of the list are all tuples to add docstrings to many attributes of an object. numpy/add_newdocs.py is a place where docstrings can be added. -Travis - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] vector to tensor matrix speed up
[EMAIL PROTECTED] wrote: Hi users, i have some problem in Numpy with indexing speed for array to tensor matrix transport. With 20 cycles it's 9sec ! (without sort(eigvals() - functions) Many thanks f. The big problem you have here is that you are operating on your matrices one element at a time. Overhead is going to kill you doing this. The key thing is to operate on your data in chunks -- I'll show one way below that speeds thing up by a factor of 40 or so *neglecting sort(eigvals())*. Unfortunately, sort(eigvals()) is still likely to kill you since there's not really a good way to chunk that up. (I'll have more to say about that in a more general sense in another email). Here's the two versions I compared, perhaps this will help you out: from numpy import * import timeit out = zeros((20,11),float) def f0(out): for j in arange(0,20): pass def f1(out): # stress values/matrix in array form for 20 points # #.out = filling matrix ...etc... # # stress tensor matrix eig = zeros((3,3),float) # #output for eigvalues eigwert = array([0,0,0]) # for j in arange(0,20): eig[0,0] = out[j,1] eig[1,1] = out[j,2] eig[2,2] = out[j,3] # eig[0,1] = out[j,4] eig[0,2] = out[j,6] eig[1,0] = out[j,4] eig[1,2] = out[j,5] eig[2,0] = out[j,6] eig[2,1] = out[j,5] # #~ eigwert = sort(eigvals(eig)) out[j,7] = eigwert[2] out[j,8] = eigwert[1] out[j,9] = eigwert[0] out[j,10] = abs(eigwert[0]-eigwert[2]) # def f2(out): # stress values/matrix in array form for 20 points # #.out = filling matrix ...etc... # # stress tensor matrix eig = zeros((100,3,3),float) # #output for eigvalues eigwert = zeros([100,3], dtype=float) # local_abs = abs rangen = range(0,20,100) for j in rangen: eig[:,0,0] = out[j:j+100,1] eig[:,1,1] = out[j:j+100,2] eig[:,2,2] = out[j:j+100,3] # eig[:,1,0] = eig[:,0,1] = out[j:j+100,4] eig[:,2,0] = eig[:,0,2] = out[j:j+100,6] eig[:,2,1] = eig[:,1,2] = out[j:j+100,5] # #~ eigwert = sort(eigvals(eig)) for j in rangen: out[j:j+100,7:10] = eigwert # Changed order of out here out[j:j+100,10] = abs(eigwert[:,0]-eigwert[:,2]) if __name__ == '__main__': print timeit.Timer(f0(out), from scratch import f0, out).timeit(1) print timeit.Timer(f1(out), from scratch import f1, out).timeit(1) print timeit.Timer(f2(out), from scratch import f2, out).timeit(1) # stress values/matrix in array form for 20 points out = zeros((20,11),Float32) # #.out = filling matrix ...etc... # # stress tensor matrix eig = zeros((3,3),Float32) # #output for eigvalues eigwert = array([0,0,0]) # for j in arange(0,20): eig[0,0] = out[j,1] eig[1,1] = out[j,2] eig[2,2] = out[j,3] # eig[0,1] = out[j,4] eig[0,2] = out[j,6] eig[1,0] = out[j,4] eig[1,2] = out[j,5] eig[2,0] = out[j,6] eig[2,1] = out[j,5] # eigwert = sort(eigvals(eig)) out[j,7] = eigwert[2] out[j,8] = eigwert[1] out[j,9] = eigwert[0] out[j,10] = abs(eigwert[0]-eigwert[2]) # - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Beta release on Thursday
On July 17, 2006, at 9:01 PM, Travis Oliphant wrote: I'd like to make release 1.0beta on Thursday. Please submit bug- reports and fixes before then. -Travis Is it possible to incorporate v7 mat-file support before the new- feature freeze? I have the fixes posted to ticket #14. Several people have contacted me about the ticket. Thanks, Nick smime.p7s Description: S/MIME cryptographic signature - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] NumPy 1.0b1 at the door...
I'm getting ready to tag the trunk as the 1.0b1 release (will be done in 2 hours unless I hear from somebody).I've taken care of most of the relevant open tickets. Some of the build issues are still there but they can be fixed during the beta release period which I expect to be several months. -Travis - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion