Re: [Numpy-discussion] 2D (or n-d) fancy indexing?
Hi Zach 2008/10/9 Zachary Pincus [EMAIL PROTECTED]: Conceptually, you need arrays A, B, and C such that composite[x,y] == images[A[x,y], B[x,y], C[x,y]] for all x,y Aha -- thanks especially for the clear illustration of what B and C need to be. That really helps. I also summarised some of the posts on this topic between Jack Cooke and Robert Kern in my SciPy'08 slides: http://mentat.za.net/numpy/numpy_advanced_slides/ I don't know if they're much use without the dialogue. Or maybe they're better :) Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Apply a vector function to each row of a matrix
David Huard wrote: Neal, Look at: apply_along_axis I guess it'd be: b = empty_like(a) for row in a.shape[0]: b[row,:] = apply_along_axis (func, row, a) I don't suppose there is a way to do this without explicitly writing a loop. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] 2D (or n-d) fancy indexing?
http://mentat.za.net/numpy/numpy_advanced_slides/ Those slides are really useful! Thanks a ton. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Apply a vector function to each row of a matrix
Neal, Look at: apply_along_axis David On Thu, Oct 9, 2008 at 8:04 AM, Neal Becker [EMAIL PROTECTED] wrote: Suppose I have a function (I wrote in c++) that accepts a numpy 1-d vector. What is the recommended way to apply it to each row of a matrix, returning a new matrix result? (Assume the function has signature newvec = f (oldvec)) ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] dtype behavior
Hi -- Can somebody here explain the following behavior: In [1]: tst = np.array([5.]) In [2]: tst Out[2]: array([ 5.]) In [3]: tst.shape Out[3]: (1,) In [4]: tst.dtype Out[4]: dtype('float64') In [5]: tst.dtype = np.int In [6]: tst Out[6]: array([ 0, 1075052544]) In [7]: tst.dtype Out[7]: dtype('int32') In [8]: tst.shape Out[8]: (2,) Is this a bug? I'm running numpy version 1.1.1 and was trying to convert the float array([5.]) to an int array([5]). ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] dtype behavior
ctw wrote: Hi -- Can somebody here explain the following behavior: In [1]: tst = np.array([5.]) In [2]: tst Out[2]: array([ 5.]) In [3]: tst.shape Out[3]: (1,) In [4]: tst.dtype Out[4]: dtype('float64') In [5]: tst.dtype = np.int In [6]: tst Out[6]: array([ 0, 1075052544]) In [7]: tst.dtype Out[7]: dtype('int32') In [8]: tst.shape Out[8]: (2,) Setting attributes of the array always just change the information about the array, they never change the memory the array points to. In this case you've taken the bits that represent float64 and re-interpreted them as int32 (that's why you know have a length 2 array). So, you are exploring the floating-point bit-pattern on your computer. If you want to cast to another data-type, then you need to use the astype method: tst = tst.astype(np.int) -Travis ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] can't build numpy 1.2.0 under python 2.6 (windows-amd64) using VS9
Thanks Hanni! That did it. Numpy builds and installs by commenting out: #ifndef HAVE_FREXPF static float frexpf(float x, int * i) { return (float)frexp((double)(x), i); } #endif #ifndef HAVE_LDEXPF static float ldexpf(float x, int i) { return (float)ldexp((double)(x), i); } #endif in numpy-1.2.0\numpy\core\src\umathmodule.c.src NOTICE- This communication (including any attachments) contains confidential and/or privileged information and is intended only for the use of the individual(s) to whom it is addressed for a specific purpose and is protected by law. Any review, use, distribution, disclosure, alteration, copying, transmittal or re-transmittal by persons who are not intended recipients of this communication may be a violation of law and is strictly prohibited. If you are not the intended recipient, please permanently delete all copies of this communication and any attachments from your computer system, destroy any hard copies, and immediately notify the sender or SSARIS Advisors, LLC at [EMAIL PROTECTED] or (203) 328-7200. No waiver of confidentiality or privilege is made by mistransmission. Any views expressed in this communication are those of the individual sender. This communication and any attachments hereto are for informational purposes only and should not be construed as an offer to sell interests or shares in any investment vehicle managed by SSARIS Advisors, LLC or its affiliates. Any information regarding trading performance must be considered in conjunction with the appropriate disclosure documents. Past performance is not necessarily indicative of future results. SSARIS Advisors, LLC reserves the right to monitor all communications through its networks. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Apply a vector function to each row of a matrix
On Thu, Oct 9, 2008 at 9:40 AM, Neal Becker [EMAIL PROTECTED] wrote: David Huard wrote: Neal, Look at: apply_along_axis I guess it'd be: b = empty_like(a) for row in a.shape[0]: b[row,:] = apply_along_axis (func, row, a) I don't suppose there is a way to do this without explicitly writing a loop. Have you tried b = apply_along_axis(func, 1, a) It should work. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] OT (NumPy slides)
http://mentat.za.net/numpy/numpy_advanced_slides/ Zachary Pincus wrote: Those slides are really useful! Thanks a ton. Nice content! And I have to add, S5 produces a beautiful show. Alan Isaac PS What did you use to produce the 3d figures? PPS Do you know why the display get muddled if you switch to full screen on FireFox? It seems to be a problem with the fixed-width font display? This is the first time I've ever seen something look better on IE than FireFox. Is it just the display I am using at work? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Apply a vector function to each row of a matrix
David Huard wrote: On Thu, Oct 9, 2008 at 9:40 AM, Neal Becker [EMAIL PROTECTED] wrote: David Huard wrote: Neal, Look at: apply_along_axis I guess it'd be: b = empty_like(a) for row in a.shape[0]: b[row,:] = apply_along_axis (func, row, a) I don't suppose there is a way to do this without explicitly writing a loop. Have you tried b = apply_along_axis(func, 1, a) It should work. Yes, thanks. The doc for apply_along_axis is not clear. For one thing, it says: The output array. The shape of outarr depends on the return value of func1d. If it returns arrays with the same shape as the input arrays it receives, outarr has the same shape as arr. What happens if the 'if' clause is not true? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] OT (NumPy slides)
http://mentat.za.net/numpy/numpy_advanced_slides/ Alan G Isaac wrote: Do you know why the display get muddled if you switch to full screen on FireFox? I received this reply: Whenever you resize an S5 display (switch to fullscreen or just resize the window), you have to reload the page (Ctrl-R or Cmd-R). S5 sizes text proportionally to the display size once when loaded. And it works. Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Proposal: scipy.spatial
I have written up basic nearest neighbor algorithm. It does a brute force search so it will be slower than kdtrees as the number of points gets large. It should however work well for high dimensional data. I have also added the option for user defined distance measures. The user can set a default p. p has the same functionality if it is a float. p can also be a function that computes a distance matrix or the measure can be selected using the strings: Manhattan, Euclidean, or Correlation. https://pyvision.svn.sourceforge.net/svnroot/pyvision/trunk/src/pyvision/vector/knn.py The interface is similar to Anne's code and in many cases can be used as a drop in replacement. I have posted the code to my own project because I have a short term need and I do not have access to the scipy repository. Feel free to include the code with scipy under the scipy license. I did find a typo your documentation. typo trie - tree - ... kd-tree is a binary trie, each of whose ... Also I found the use of k in the documentation some what confusing as it is the dimensionality of the data points in the kd-tree and the number of neighbors for k-nearest neighbors. I believe that with mean subtracted and unit length vectors, a Euclidean knn algorithm will produces the same result as if the vectors were compared using correlation. I am not sure if kd-trees will perform well on the normalized vectors as they have a very specific geometry. If my math checks out it may be worth adding Pearson's correlation as a default option or as a separate class. Actually it's probably easier if the user just does the prenormalization. I agree. I think we should keep your class as-is and maybe create a class that wraps the kdtree and handles the normalization for correlation. I would also like to look at cover trees, however that will have to wait a couple months until I have more time. Dave --- http://www.cs.colostate.edu/~bolme ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't build numpy 1.2.0 under python 2.6 (windows-amd64) using VS9
On Wednesday 08 October 2008 10:56:02 Hanni Ali wrote: We discussed errors you are encountering a few months ago, they are related to the compiler directives. #ifndef HAVE_FREXPF static float frexpf(float x, int * i) { return (float)frexp((double)(x), i); } #endif #ifndef HAVE_LDEXPF static float ldexpf(float x, int i) { return (float)ldexp((double)(x), i); } #endif Commenting out this section at line 64 allow compilation and has no ill effects. Given that commenting out the section above allows numpy to compile without any apparent side effects, is there any chance we could get experimental binaries of numpy 1.2.0 for python 2.6? I do understand that a negative answer is very likely and the reasons therefor. Regards, Ravi ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] OT (NumPy slides)
Hi Alan 2008/10/9 Alan G Isaac [EMAIL PROTECTED]: http://mentat.za.net/numpy/numpy_advanced_slides/ Nice content! Thanks! As you can see, I enjoyed myself at SciPy'08 :) And I have to add, S5 produces a beautiful show. This slide show incorporates the changes from S5 Reloaded: http://www.netzgesta.de/S5/references.php I put the sources for generating the slides on http://mentat.za.net/numpy/numpy_advanced_slides_sources.tar.bz2 This includes the custom rst2s5 script that does Python highlighting with Pyglet, and which executes all code snippets as tests. PS What did you use to produce the 3d figures? I'm not sure I want to mention it out loud, but... Google Sketchup, scripted using Ruby. I hope someone finds it useful. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Please backport fixes to the 1.2.x branch
On Sun, Oct 5, 2008 at 7:59 PM, Jarrod Millman [EMAIL PROTECTED] wrote: I would like to get a 1.2.1 release out ASAP. There are several bug-fixes on the trunk that need to be backported. If you have made a bug-fix to the trunk that you have been waiting to backport to the 1.2.x branch, please do so now: http://svn.scipy.org/svn/numpy/branches/1.2.x Ideally, I would like to freeze the branch for the 1.2.1 release in about 1 week. Please let me know if you need more time or if there is something in particular that you would like to see backported. Hey, Is anyone planning to back port anymore fixes to the 1.2.x branch? So this is all that has been back ported: bug fix for subclassing object arrays: http://projects.scipy.org/scipy/numpy/changeset/5891 MaskedArray fixes: http://projects.scipy.org/scipy/numpy/changeset/5936 Python 2.4 compatible lookfor: http://projects.scipy.org/scipy/numpy/changeset/5945 -- Jarrod Millman Computational Infrastructure for Research Labs 10 Giannini Hall, UC Berkeley phone: 510.643.4014 http://cirl.berkeley.edu/ ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Please backport fixes to the 1.2.x branch
I would also like to back port revision 5833: http://projects.scipy.org/scipy/numpy/changeset/5833 Are there any other fixes that should be back ported? -- Jarrod Millman Computational Infrastructure for Research Labs 10 Giannini Hall, UC Berkeley phone: 510.643.4014 http://cirl.berkeley.edu/ ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion