Re: [Numpy-discussion] PyGTK breaks fortran extension???

2010-09-03 Thread Pauli Virtanen
Fri, 03 Sep 2010 08:53:00 +0300, Åsmund Hjulstad wrote: I have a f2py wrapped fortran extension, compiled using gcc-mingw32 (v.4.5.0), numpy 1.5, Python 2.7, where I am experiencing the strangest behaviour. It appears that loading pygtk breaks my fortran extension. Be aware that import gtk

[Numpy-discussion] Help with the tensordot function?

2010-09-03 Thread Rick Muller
Can someone help me replace a slow expression with a faster one based on tensordot? I've read the documentation and I'm still confused. I have two matrices b and d. b is n x m and d is m x m. I want to replace the expression bdb = zeros(n,'d') for i in xrange(n): bdb[i,:] =

[Numpy-discussion] Simplified question on tensordot

2010-09-03 Thread Rick Muller
Sorry for the rapid repost, but I thought of a much easier way to ask the question I asked a few minutes ago. I have two matrices, A and B, both of which are n x m. n is big (~10,000), and m is small (~10). I want to take the product AB such that I get a length-n vector, as in: AB =

Re: [Numpy-discussion] Simplified question on tensordot

2010-09-03 Thread josef . pktd
On Fri, Sep 3, 2010 at 7:48 AM, Rick Muller rpmul...@gmail.com wrote: Sorry for the rapid repost, but I thought of a much easier way to ask the question I asked a few minutes ago. I have two matrices, A and B, both of which are n x m. n is big (~10,000), and m is small (~10). I want to take

Re: [Numpy-discussion] Simplified question on tensordot

2010-09-03 Thread Rick Muller
Josef and Pauli, Wow, you guys rock! I'm amazed you could pull that out so quickly. I thank you, and PyQuante thanks you (hopefully this will make for faster density functional theory grids). Rick On Fri, Sep 3, 2010 at 5:59 AM, josef.p...@gmail.com wrote: On Fri, Sep 3, 2010 at 7:48 AM,

[Numpy-discussion] recarray to csv

2010-09-03 Thread Guillaume Chérel
Hello, I'd like to know if there is a convenient routine to write recarrays into cvs files, with the first line of the file being the name of the fields. Thanks, Guillaume ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] recarray to csv

2010-09-03 Thread Guillaume Chérel
Great, Thank you. I also found out about csv2rec. I've been missing these two a lot. Le 03/09/2010 15:35, Pierre GM a écrit : On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote: Hello, I'd like to know if there is a convenient routine to write recarrays into cvs files, with the first

Re: [Numpy-discussion] recarray to csv

2010-09-03 Thread Benjamin Root
On Fri, Sep 3, 2010 at 8:35 AM, Pierre GM pgmdevl...@gmail.com wrote: On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote: Hello, I'd like to know if there is a convenient routine to write recarrays into cvs files, with the first line of the file being the name of the fields.

Re: [Numpy-discussion] recarray to csv

2010-09-03 Thread Erin Sheldon
Excerpts from Guillaume Chérel's message of Fri Sep 03 09:32:02 -0400 2010: Hello, I'd like to know if there is a convenient routine to write recarrays into cvs files, with the first line of the file being the name of the fields. Thanks, Guillaume Yes, you can do this with the

Re: [Numpy-discussion] recarray to csv

2010-09-03 Thread John Hunter
2010/9/3 Guillaume Chérel guillaume.c.che...@gmail.com:  Great, Thank you. I also found out about csv2rec. I've been missing these two a lot. Some other handy rec functions in mlab http://matplotlib.sourceforge.net/examples/misc/rec_groupby_demo.html

Re: [Numpy-discussion] recarray to csv

2010-09-03 Thread John Hunter
On Fri, Sep 3, 2010 at 8:50 AM, Benjamin Root ben.r...@ou.edu wrote: Why is this function in matplotlib?  Wouldn't it be more useful in numpy? I tend to add stuff I write to matplotlib. mlab was initially a repository of matlab-like functions that were not available in numpy (load, save,

[Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Rick Muller
There just *has* to be a better way of doing this. I want to cut off small values of a vector, and I'm currently doing something like: for i in xrange(n): if abs(A[i]) tol: A[i] = 0 Which is slow, since A can be really long. Is there a way to write a Ufunc that would do something like this

Re: [Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Keith Goodman
On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller rpmul...@gmail.com wrote: There just *has* to be a better way of doing this. I want to cut off small values of a vector, and I'm currently doing something like: for i in xrange(n):     if abs(A[i]) tol: A[i] = 0 Which is slow, since A can be

Re: [Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Rick Muller
Sweet! Guess I need to learn more about numpy indexing: this is pretty powerful. On Fri, Sep 3, 2010 at 10:42 AM, Keith Goodman kwgood...@gmail.com wrote: On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller rpmul...@gmail.com wrote: There just *has* to be a better way of doing this. I want to cut off

[Numpy-discussion] Add function for creating recarray from database query?

2010-09-03 Thread John Salvatier
Hello, I recently had to get data from a mysql database into a recarray. The result was not very long but nontrivial to figure out: def recarray_from_db(db, command): executes a command and turns the results into a numpy recarray (record array) cursor = db.cursor()