Re: [Numpy-discussion] Python Magazine
On Fri, 05 Oct 2007, Christopher Barker apparently wrote: > There is a new Python Magazine out there: > http://www.pythonmagazine.com/ Looks useful. If you think so too, make sure you library subscribes. Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Memory leak in vectorize ?
Hello, the following code seems to create a memory leak in Python. (around 230 MB). Any ideas what's wrong ? I'm using python 2.5 and numpy 1.0.3 --- def toto(x): return x**2 tutu=vectorize(toto) Nbins=1 for i in xrange(1000): c=tutu(arange(Nbins)) --- Thanks, Cyrille. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Interested in adding new data type
I'm interested in experimenting with adding complex data type. I have "Guide to Numpy". I'm looking at section 15.3. It looks like the first thing is a PyArray_Desc. There doesn't seem to be much info on what needs to go in this. Does anyone have any examples I could look at? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Iterate over all 1-dim views
On Sun, Oct 07, 2007 at 06:52:11AM -0400, Neal Becker wrote: > Suppose I have a function F(), which is defined for 1-dim arguments. If the > user passes an n>1 dim array, I want to apply F to each 1-dim view. > For example, for a 2-d array, apply F to each row and return a 2-d result. > For a 3-d array, select each 2-d subarray and see above. Return 3-d result. > Any suggestions on how to code something like this in numpy? Code your function so that it works well for 2D arrays (using axis=-1 and co), then use a decorator on it so that if you pass it an N-d array, it transforms it in a 2D array, passes it to the decorator, then transforms the output back to the right shape. The idea is quite theoretical, and I have never gotten to implement it, because when I was facing similar problems, it didn't come to my mind, but I think it can work in a very general way. Gaƫl ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Iterate over all 1-dim views
Neal Becker <[EMAIL PROTECTED]> kirjoitti: > Suppose I have a function F(), which is defined for 1-dim arguments. If the > user passes an n>1 dim array, I want to apply F to each 1-dim view. > > For example, for a 2-d array, apply F to each row and return a 2-d result. > > For a 3-d array, select each 2-d subarray and see above. Return 3-d result. > > Any suggestions on how to code something like this in numpy? You may be looking for numpy.apply_along_axis: >>> from numpy import * >>> x=arange(2*3*4); x.shape=(2,3,4) >>> x array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]]) >>> apply_along_axis(cumsum, 0, x) array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 14, 16, 18], [20, 22, 24, 26], [28, 30, 32, 34]]]) >>> apply_along_axis(cumsum, 1, x) array([[[ 0, 1, 2, 3], [ 4, 6, 8, 10], [12, 15, 18, 21]], [[12, 13, 14, 15], [28, 30, 32, 34], [48, 51, 54, 57]]]) >>> apply_along_axis(cumsum, 2, x) array([[[ 0, 1, 3, 6], [ 4, 9, 15, 22], [ 8, 17, 27, 38]], [[12, 25, 39, 54], [16, 33, 51, 70], [20, 41, 63, 86]]]) -- ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Iterate over all 1-dim views
Suppose I have a function F(), which is defined for 1-dim arguments. If the user passes an n>1 dim array, I want to apply F to each 1-dim view. For example, for a 2-d array, apply F to each row and return a 2-d result. For a 3-d array, select each 2-d subarray and see above. Return 3-d result. Any suggestions on how to code something like this in numpy? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion