[Numpy-discussion] distance matrix speed

2006-06-16 Thread Sebastian Beca
Hi, I'm working with NumPy/SciPy on some algorithms and i've run into some important speed differences wrt Matlab 7. I've narrowed the main speed problem down to the operation of finding the euclidean distance between two matrices that share one dimension rank (dist in Matlab): Python: def

Re: [Numpy-discussion] distance matrix speed

2006-06-16 Thread Michael Sorich
Hi Sebastian, I am not sure if there is a function already defined in numpy, but something like this may be what you are after def distance(a1, a2): return sqrt(sum((a1[:,newaxis,:] - a2[newaxis,:,:])**2, axis=2)) The general idea is to avoid loops if you want the code to execute fast. I

Re: [Numpy-discussion] distance matrix speed

2006-06-16 Thread Johannes Loehnert
Hi, def dtest():     A = random( [4,2])     B = random( [1000,2]) # drawback: memory usage temporarily doubled # solution see below d = A[:, newaxis, :] - B[newaxis, :, :] # written as 3 expressions for more clarity d = sqrt((d**2).sum(axis=2)) return d def

Re: [Numpy-discussion] Supporting both NumPy and Numeric versions of amodule

2006-06-16 Thread Konrad Hinsen
We are using Python's distutils, and I'm trying to figure out if there's a way in which I can have both distributions installed to one package directory, and then the __init__.py file would try to figure out which one to import on behalf of the user (i.e. it would try to figure out if the

Re: [Numpy-discussion] Don't like the short names like lstsq and irefft

2006-06-16 Thread Sven Schreiber
Alexander Belopolsky schrieb: In my view it is more important that code is easy to read rather than easy to write. Interactive users will disagree, but in programming you write once and read/edit forever :). The insight about this disagreement imho suggests a compromise (or call it a dual

[Numpy-discussion] Test post - ignore

2006-06-16 Thread Sebastian Beca
Please ignore if you recieve this. ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion

[Numpy-discussion] ImportError while creating a Python module using NumPy

2006-06-16 Thread Pierre Barbier de Reuille
Hi, I have an extension library which I wanted to interface with NumPy ... So I added the import_array() and all the needed stuff so that it now compiles. However, when I load the library I obtain : ImportError: No module named core.multiarray I didn't find anything on the net about it, what

Re: [Numpy-discussion] Don't like the short names like lstsq and irefft

2006-06-16 Thread Alexandre Fayolle
On Fri, Jun 16, 2006 at 10:43:42AM +0200, Sven Schreiber wrote: Again, there is no defense for abbreviating linear_least_squares because it is unlikely to appear in an expression and waste valuable horisontal space. not true imho; btw, I would suggest ols (ordinary least squares),

Re: [Numpy-discussion] Don't like the short names like lstsq and irefft

2006-06-16 Thread Sven Schreiber
Alexandre Fayolle schrieb: On Fri, Jun 16, 2006 at 10:43:42AM +0200, Sven Schreiber wrote: Again, there is no defense for abbreviating linear_least_squares because it is unlikely to appear in an expression and waste valuable horisontal space. not true imho; btw, I would suggest ols

Re: [Numpy-discussion] Don't like the short names like lstsq and irefft

2006-06-16 Thread Tim Hochberg
I don't have anything constructive to add at the moment, so I'll just throw out an unelucidated opinion: +1 for longish names. -1 for two sets of names. -tim ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net

[Numpy-discussion] Numpy svn not installing headers

2006-06-16 Thread Matt Hyclak
I was trying to build matplotlib after installing the latest svn version of numpy (r2426), and compilation bailed on missing headers. It seems that the headers from build/src.linux*/numpy/core/ are not properly being installed during setup.py's install phase to

Re: [Numpy-discussion] distance matrix speed

2006-06-16 Thread Tim Hochberg
Sebastian Beca wrote: Hi, I'm working with NumPy/SciPy on some algorithms and i've run into some important speed differences wrt Matlab 7. I've narrowed the main speed problem down to the operation of finding the euclidean distance between two matrices that share one dimension rank (dist in

Re: [Numpy-discussion] Don't like the short names like lstsq and irefft

2006-06-16 Thread Sasha
On 6/16/06, Sven Schreiber [EMAIL PROTECTED] wrote: Abbreviations will emerge anyway, the question is merely: Will numpy provide/recommend them (in addition to having long names maybe), or will it have to be done by somebody else, possibly resulting in many different sets of

Re: [Numpy-discussion] Segfault with simplest operation on extension module using numpy

2006-06-16 Thread Robert Kern
Glen W. Mabey wrote: That is, when I run: import DFALG DFALG.bsvmdf( 3 ) after compiling the below code, it always segfaults, regardless of the type of the argument given. Just as a sanity check (it's been a little while since I have written an extension module for Python) I

Re: [Numpy-discussion] Distance Matrix speed

2006-06-16 Thread Tim Hochberg
Christopher Barker wrote: Bruce Southey wrote: Please run the exact same code in Matlab that you are running in NumPy. Many of Matlab functions are very highly optimized so these are provided as binary functions. I think that you are running into this so you are not doing the correct

[Numpy-discussion] tiny patch + Playing with strings and my own array descr (PyArray_STRING, PyArray_OBJECT).

2006-06-16 Thread Matthieu Perrot
hi, I need to handle strings shaped by a numpy array whose data own to a C structure. There is several possible answers to this problem : 1) use a numpy array of strings (PyArray_STRING) and so a (char *) object in C. It works as is, but you need to define a maximum size to your strings

Re: [Numpy-discussion] Array Protocol change for Python 2.6

2006-06-16 Thread Thomas Heller
Robert Kern wrote: Francesc Altet wrote: A Divendres 09 Juny 2006 11:54, Albert Strasheim va escriure: Just out of curiosity: In [1]: x = N.array([]) In [2]: x.__array_data__ Out[2]: ('0x01C23EE0', False) Is there a reason why the __array_data__ tuple stores the address as a hex string? I

Re: [Numpy-discussion] Array Protocol change for Python 2.6

2006-06-16 Thread Francesc Altet
A Divendres 16 Juny 2006 21:25, Thomas Heller va escriure: Robert Kern wrote: Like how Win64 uses 32-bit longs and 64-bit pointers. And then there's signedness. Please don't use Python ints to encode pointers. Holding arbitrary pointers is the job of CObjects. (Sorry, I'm late in reading

Re: [Numpy-discussion] Array Interface

2006-06-16 Thread Thomas Heller
Travis Oliphant wrote: Thanks for the continuing discussion on the array interface. I'm thinking about this right now, because I just spent several hours trying to figure out if it is possible to add additional object-behavior pointers to a type by creating a metatype that sub-types from

[Numpy-discussion] Recarray attributes writeable

2006-06-16 Thread Erin Sheldon
Hi everyone - (this is my fourth try in the last 24 hours to post this. Apparently, the gmail smtp server is in the blacklist!! this is bad). Anyway - Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are

[Numpy-discussion] Recarray attributes writeable (3rd try)

2006-06-16 Thread Erin Sheldon
Hi everyone - (this is my third try in the last 24 hours to post this. For some reason it hasn't been making it through) Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are designed for read only; one cannot

Re: [Numpy-discussion] Recarray attributes writeable

2006-06-16 Thread Robert Kern
Erin Sheldon wrote: Hi everyone - (this is my fourth try in the last 24 hours to post this. Apparently, the gmail smtp server is in the blacklist!! this is bad). I doubt it since that's where my email goes through. Sourceforge is frequently slow, so please have patience if your mail does

Re: [Numpy-discussion] Array Protocol change for Python 2.6

2006-06-16 Thread Travis Oliphant
Thomas Heller wrote: Robert Kern wrote: Francesc Altet wrote: A Divendres 09 Juny 2006 11:54, Albert Strasheim va escriure: Just out of curiosity: In [1]: x = N.array([]) In [2]: x.__array_data__ Out[2]: ('0x01C23EE0', False) Is there a reason why the __array_data__

Re: [Numpy-discussion] Recarray attributes writeable

2006-06-16 Thread Andrew Straw
Erin Sheldon wrote: Anyway - Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are designed for read only; one cannot alter the data through them. Yet they are writeable: tr=numpy.recarray(10,

Re: [Numpy-discussion] Recarray attributes writeable

2006-06-16 Thread Erin Sheldon
The initial bounces actually say, and I quote: Technical details of temporary failure: TEMP_FAILURE: SMTP Error (state 8): 550-rejected because your SMTP server, 66.249.92.170, is in the Spamcop RBL. 550 See http://www.spamcop.net/bl.shtml for more information. On 6/16/06, Robert Kern [EMAIL

[Numpy-discussion] installing numpy and removing numeric-24.

2006-06-16 Thread Jon Chock
Hi folks! Id like to install numpy and remove numeric, are there instructions to remove numeric-24.1? Thanks. JC ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net

[Numpy-discussion] installing numpy and removing numeric-24.1

2006-06-16 Thread Jon Chock
Sorry, I forgot to mention that Im working on a Solaris system and installed it in /usr/local/gcc3xbuilt instead of /usr/local. Thanks. JC ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net

[Numpy-discussion] Array interface updated to Version 3

2006-06-16 Thread Travis Oliphant
I just updated the array interface page to emphasize we now have version 3. NumPy still supports objects that expose (the C-side) of version 2 of the array interface, though. The new interface is basically the same except (mostly) for asthetics: The differences are listed at the bottom of

Re: [Numpy-discussion] Array interface updated to Version 3

2006-06-16 Thread Fernando Perez
On 6/16/06, Travis Oliphant [EMAIL PROTECTED] wrote: There is talk of ctypes supporting the new interface which is a worthy development. Please encourage that if you can. That would certainly be excellent, esp. given how ctypes is slated to be officially part of python 2.5. I think it would

Re: [Numpy-discussion] Array interface updated to Version 3

2006-06-16 Thread Andrew Straw
I noticed in your note labeled 'June 16, 2006' that you refer to the desc field. However, in the struct description above, there is only a field named descr. Also, I suggest that you update the information in the comments of descr field of the structure description to contain the fact that

Re: [Numpy-discussion] Distance Matrix speed

2006-06-16 Thread Sebastian Beca
Thanks! Avoiding the inner loop is MUCH faster (~20-300 times than the original). Nevertheless I don't think I can use hypot as it only works for two dimensions. The general problem I have is: A = random( [C, K] ) B = random( [N, K] ) C ~ 1-10 N ~ Large (thousands, millions.. i.e. my dataset) K

Re: [Numpy-discussion] Distance Matrix speed

2006-06-16 Thread Sebastian Beca
Please replace: C = 4 N = 1000 d = zeros([C, N], dtype=float) BK. ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion