Re: [Numpy-discussion] Selecting columns of a matrix

2006-06-20 Thread Keith Goodman
On 6/20/06, Bill Baxter [EMAIL PROTECTED] wrote: I think that one's on the NumPy for Matlab users, no? http://www.scipy.org/NumPy_for_Matlab_Users import numpy as num a = num.arange (10).reshape(2,5) a array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) v = num.rand(5) v array([

Re: [Numpy-discussion] Selecting columns of a matrix

2006-06-21 Thread Keith Goodman
On 6/20/06, Bill Baxter [EMAIL PROTECTED] wrote: a[:,num.where(v0.5)[0]] array([[1, 2, 4], [6, 7, 9]]) I'll put that up on the Matlab-Numpy page. That's a great addition to the Matlab to Numpy page. But it only works if v is a column vector. If v is a row vector, then where(v.A

[Numpy-discussion] Element-by-element matrix multiplication

2006-06-21 Thread Keith Goodman
The NumPy for Matlab Users page suggests mat(a.A * b.A) for element-by-element matrix multiplication. I think it would be helpful to also include multiply(a, b). a.*b mat(a.A * b.A) or multiply(a, b) ___ Numpy-discussion mailing list

Re: [Numpy-discussion] Element-by-element matrix multiplication

2006-06-21 Thread Keith Goodman
On 6/21/06, Robert Kern [EMAIL PROTECTED] wrote: Keith Goodman wrote: The NumPy for Matlab Users page suggests mat(a.A * b.A) for element-by-element matrix multiplication. I think it would be helpful to also include multiply(a, b). a.*b mat(a.A * b.A) or multiply(a, b

Re: [Numpy-discussion] How do I seed the radom number generator?

2006-06-22 Thread Keith Goodman
On 6/22/06, Robert Kern [EMAIL PROTECTED] wrote: Keith Goodman wrote: How do I seed rand and randn? If you can, please use the .rand() and .randn() methods on a RandomState object which you can initialize with whatever seed you like. In [1]: import numpy as np rs In [2]: rs

[Numpy-discussion] How do I make a diagonal matrix?

2006-06-23 Thread Keith Goodman
How do I make a NxN diagonal matrix with a Nx1 column vector x along the diagonal? Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on

Re: [Numpy-discussion] indexing bug in numpy r2694

2006-06-28 Thread Keith Goodman
On 6/28/06, Travis Oliphant [EMAIL PROTECTED] wrote: Keith Goodman wrote: On 6/28/06, Pau Gargallo [EMAIL PROTECTED] wrote: i don't know why 'where' is returning matrices. if you use: idx = where(y.A 0.5)[0] everything will work fine (I guess) What about the second

Re: [Numpy-discussion] indexing bug in numpy r2694

2006-06-28 Thread Keith Goodman
On 6/28/06, Travis Oliphant [EMAIL PROTECTED] wrote: This should be better behaved now in SVN. Thanks for the reports. I'm impressed by how quickly features are added and bugs are fixed. And by how quick it is to install a new version of numpy. Thank you. Using Tomcat but need to do more?

Re: [Numpy-discussion] Time for beta1 of NumPy 1.0

2006-06-29 Thread Keith Goodman
On 6/29/06, Alan G Isaac [EMAIL PROTECTED] wrote: On Thu, 29 Jun 2006, Travis Oliphant apparently wrote: Please make any comments or voice major concerns A rather minor issue, but I would just like to make sure that a policy decision was made not to move to a float default for identity(),

Re: [Numpy-discussion] Time for beta1 of NumPy 1.0

2006-06-29 Thread Keith Goodman
On 6/29/06, Bill Baxter [EMAIL PROTECTED] wrote: I also find the int behavior of these functions strange. +1 float default (or double) Oh, wait. Which do I want, float or double? What does rand, eigh, lstsq, etc return? Using Tomcat but need to do more? Need to support web services, security?

Re: [Numpy-discussion] Time for beta1 of NumPy 1.0

2006-06-30 Thread Keith Goodman
On 6/29/06, Alan G Isaac [EMAIL PROTECTED] wrote: On Thu, 29 Jun 2006, Travis Oliphant apparently wrote: Please make any comments or voice major concerns A rather minor issue, but I would just like to make sure that a policy decision was made not to move to a float default for identity(),

Re: [Numpy-discussion] Time for beta1 of NumPy 1.0

2006-06-30 Thread Keith Goodman
On 6/30/06, Sasha [EMAIL PROTECTED] wrote: On 6/30/06, Fernando Perez [EMAIL PROTECTED] wrote: ... Besides, decent unit tests will catch these problems. We all know that every scientific code in existence is unit tested to the smallest routine, so this shouldn't be a problem for anyone.

[Numpy-discussion] Matrix print plea

2006-06-30 Thread Keith Goodman
When an array is printed, the numbers line up in nice columns (if you're using a fixed-width font): array([[0, 0], [0, 0]]) But for matrices the columns do not line up: matrix([[0, 0], [0, 0]]) Using Tomcat but need to do more? Need to support web services, security? Get stuff

Re: [Numpy-discussion] Matrix print plea

2006-06-30 Thread Keith Goodman
On 6/30/06, David M. Cooke [EMAIL PROTECTED] wrote: On Fri, 30 Jun 2006 13:37:01 -0700 Keith Goodman [EMAIL PROTECTED] wrote: When an array is printed, the numbers line up in nice columns (if you're using a fixed-width font): array([[0, 0], [0, 0]]) But for matrices

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Keith Goodman
On 7/6/06, Sven Schreiber [EMAIL PROTECTED] wrote: Maybe you guys as the developers of numpy should really make up your mind about the future of matrices in numpy. Either it's supported, then eventually I would expect matrix versions of ones, zeros, eye, for example. (Although eye().M would

Re: [Numpy-discussion] simple question

2006-07-06 Thread Keith Goodman
On 7/6/06, Travis Oliphant [EMAIL PROTECTED] wrote: Mathew Yeates wrote: Not working. A[row,all_dates == 10] = -1 where all_dates is a matrix with column length of 14 [[960111,..,.. and A is a matrix with same column length I get IndexError: arrays used as indices must be of integer type

Re: [Numpy-discussion] More zaniness Re: simple question

2006-07-06 Thread Keith Goodman
On 7/6/06, Mathew Yeates [EMAIL PROTECTED] wrote: okay, I went back to the binary windows distrib. Based on Keths code I wrote print numpy.asmatrix(all_dates == start_dates[row],dtype=int) [[0 0 0 0 0 0 0 0 0 0 0 1 0 0]] [row,numpy.asmatrix(all_dates == start_dates[row],dtype=int)] = -1

Re: [Numpy-discussion] What's wrong with matrices?

2006-07-07 Thread Keith Goodman
On 7/7/06, Ed Schofield [EMAIL PROTECTED] wrote: I'd like to help to make matrices more usable. Tell me what you want, and I'll work on some patches. I can't pass up an offer like that. DIAG diag(M) returns an array. It would be nice if diag(M) returned asmatrix(diag(M)).T. It would also

Re: [Numpy-discussion] Testing a self-compiled numpy

2006-07-09 Thread Keith Goodman
On 7/9/06, Bill Baxter [EMAIL PROTECTED] wrote: I got numpy compiled according the the instruction on the Wiki, but is there some way to try it out without wiping out my stable install of 0.9.8? I tried modifying my PYTHONPATH to put the new numpy build directory first, but 'import numpy'

Re: [Numpy-discussion] Testing a self-compiled numpy

2006-07-09 Thread Keith Goodman
On 7/9/06, Bill Baxter [EMAIL PROTECTED] wrote: Thanks for the reply Keith. On 7/10/06, Keith Goodman [EMAIL PROTECTED] wrote: One quick hack is to install the new numpy somewhere else and then rename the directory containing 0.9.8 to numpySTOP. Then you don't have to worry about

Re: [Numpy-discussion] .M .A .T .H attribute result

2006-07-10 Thread Keith Goodman
On 7/7/06, Travis Oliphant [EMAIL PROTECTED] wrote: a numpy.matlib module was started to store matrix versions of the standard array-creation functions and mat was re-labeled to asmatrix so that a copy is not made by default. Holy crap! It works. This is great. Thank you. import

Re: [Numpy-discussion] suggestions for Matrix-related changes

2006-07-11 Thread Keith Goodman
On 7/11/06, David Huard [EMAIL PROTECTED] wrote: 2006/7/11, JJ [EMAIL PROTECTED]: 1) is it possible to get the function unique() to work with matrices, perhaps with a unique_rows() function to work with matrices of more than one column? The problem is that applying unique to different

Re: [Numpy-discussion] Atlas and dual core

2006-07-15 Thread Keith Goodman
On 7/15/06, Steve Lianoglou [EMAIL PROTECTED] wrote: 1) Did you install ubuntu by way of Parallels, or are you running linux full steam Yes, it is a full steam dual boot system. My default boot is Ubuntu. 2) If you did install ubuntu alongside/over/whatever mac os x and didn't use parallels

Re: [Numpy-discussion] Displaying all the rows of large matrix

2006-07-17 Thread Keith Goodman
On 7/17/06, Travis Oliphant [EMAIL PROTECTED] wrote: Keith Goodman wrote: How do you display all of the rows of a matrix? help(numpy.set_prinoptions) That is great! Now I can change the precision as well. Eight significant figures is too precise for me. Does anyone out there save

Re: [Numpy-discussion] fixing diag() for matrices

2006-07-28 Thread Keith Goodman
Every time I want to make a diagonal matrix from a vector I have to do a google search. So I'm with you Sven: diag(NxN matrix) should return a Nx1 matrix diag(Nx1 or 1xN matrix) should return a NxN matrix instead of the current behavior: diag(NxN matrix) returns an array diag(Nx1 matrix)

Re: [Numpy-discussion] some work on arpack

2006-08-16 Thread Keith Goodman
On 8/15/06, David Grant [EMAIL PROTECTED] wrote: My idea is (if I have time) to write an eigs-like function in python that will only perform a subset of what Matlab's eigs does for. It will, for example, compute a certain number of eigenvalues and eigenvectors for a real, sparse, symmetric

Re: [Numpy-discussion] Deleting a row from a matrix

2006-08-26 Thread Keith Goodman
On 8/26/06, Bill Baxter [EMAIL PROTECTED] wrote: On 8/26/06, Travis Oliphant [EMAIL PROTECTED] wrote: I've come up with adding the functions (not methods at this point) deletefrom insertinto delete and insert really would be better. The current insert function seems inaptly

[Numpy-discussion] For loop tips

2006-08-29 Thread Keith Goodman
I have a very long list that contains many repeated elements. The elements of the list can be either all numbers, or all strings, or all dates [datetime.date]. I want to convert the list into a matrix where each unique element of the list is assigned a consecutive integer starting from zero.

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Keith Goodman
On 8/29/06, Tim Hochberg [EMAIL PROTECTED] wrote: Keith Goodman wrote: I have a very long list that contains many repeated elements. The elements of the list can be either all numbers, or all strings, or all dates [datetime.date]. I want to convert the list into a matrix where each

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Keith Goodman
On 8/29/06, Torgil Svensson [EMAIL PROTECTED] wrote: something like this? def list2index(L): uL=sorted(set(L)) idx=dict((y,x) for x,y in enumerate(uL)) return uL,asmatrix(fromiter((idx[x] for x in L),dtype=int)) Wow. That's amazing. Thank you.

Re: [Numpy-discussion] stumped numpy user seeks help

2006-08-29 Thread Keith Goodman
On 8/29/06, Mathew Yeates [EMAIL PROTECTED] wrote: I have an M by N array of floats. Associated with the columns are character labels ['a','b','b','c','d','e','e','e'] note: already sorted so duplicates are contiguous I want to replace the 2 'b' columns with the sum of the 2 columns.

[Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Keith Goodman
In what order would you like argsort to sort the values -inf, nan, inf? In numpy 1.0b1 nan is always left where it began: EXAMPLE 1 x matrix([[ inf], [ -inf], [ nan]]) x[x.argsort(0),:] matrix([[ -inf], [

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Keith Goodman
On 9/19/06, A. M. Archibald [EMAIL PROTECTED] wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: Keith Goodman wrote: In what order would you like argsort to sort the values -inf, nan, inf? Ideally, -inf should sort first, inf should sort last and nan should raise an exception

Re: [Numpy-discussion] If you don't want to receive $5000 per month then don't open that letter

2006-09-20 Thread Keith Goodman
I like the salutation of the letter below: Please read this letter attentively! Why does so much spam make it through the sourceforge filters? Or maybe they only let through the very good deals. You will earn from 1500 up to 3000 USD per week, working only some hours per day. On Wed, 20 Sep

Re: [Numpy-discussion] ide for python/numpy/scipy/mpl, development ?

2006-10-09 Thread Keith Goodman
On 10/9/06, Eric Emsellem [EMAIL PROTECTED] wrote: thanks for the pointer to pida. I installed it successfully but I didn't manage to makeit really work [snip] I was excited to see that pida can use meld. But when I try to do a diff, pida complains that it cannot find meldembed.py. Has

Re: [Numpy-discussion] asmatrix and asarray exception

2006-10-11 Thread Keith Goodman
On 10/11/06, Keith Goodman [EMAIL PROTECTED] wrote: This works: M.asmatrix(['a', 'b', None]) matrix([[a, b, None]], dtype=object) But this doesn't: M.asmatrix(['a', 'b', None, 'c']) TypeError: expected a readable buffer object M.__version__ '1.0rc1' It also doesn't work

Re: [Numpy-discussion] some work on arpack

2006-10-21 Thread Keith Goodman
On 8/15/06, David Grant [EMAIL PROTECTED] wrote: My idea is (if I have time) to write an eigs-like function in python that will only perform a subset of what Matlab's eigs does for. It will, for example, compute a certain number of eigenvalues and eigenvectors for a real, sparse, symmetric

Re: [Numpy-discussion] some work on arpack

2006-10-22 Thread Keith Goodman
On 10/22/06, Aric Hagberg [EMAIL PROTECTED] wrote: On Sat, Oct 21, 2006 at 02:05:42PM -0700, Keith Goodman wrote: Did you, or anybody else on the list, have any luck making a numpy version of eigs? I made a start at an ARPACK wrapper, see http://projects.scipy.org/scipy/scipy/ticket/231

Re: [Numpy-discussion] slicing suggestion

2006-10-23 Thread Keith Goodman
On 10/23/06, Travis Oliphant [EMAIL PROTECTED] wrote: Keith Goodman wrote: On 10/20/06, JJ [EMAIL PROTECTED] wrote: My suggestion is to create a new attribute, such as .AR, so that the following could be used: M[K.AR,:] It would be even better if M[K,:] worked. Would such a patch

Re: [Numpy-discussion] Sorting eigenvalues and vectors together

2006-10-27 Thread Keith Goodman
On 10/27/06, jeremito [EMAIL PROTECTED] wrote: I am using a = numpy.linalg.eig(A) to get the eigenvalues and eigenvectors. I am interested only in the largest eigenvalue so I would like to sort the first element of a. But if I do that, I won't know what is the associated eigenvector. Is

Re: [Numpy-discussion] matrix multiplication (newbie question)

2006-11-08 Thread Keith Goodman
On 11/8/06, izak marais [EMAIL PROTECTED] wrote: Sorry if this is an obvious question, but what is the easiest way to multiply matrices in numpy? Suppose I want to do A=B*C*D. The ' * ' operator apparently does element wise multiplication, as does the 'multiply' ufunc. All I could find was

[Numpy-discussion] Assign NaN, get zero

2006-11-11 Thread Keith Goodman
I accidentally wrote a unit test using int32 instead of float64 and ran into this problem: x = M.matrix([[1, 2, 3]]) x[0,1] = M.nan x matrix([[1, 0, 3]]) --- Got 0 instead of NaN But this, of course, works: x = M.matrix([[1.0, 2.0, 3.0]]) x[0,1] = M.nan x matrix([[ 1.,

Re: [Numpy-discussion] Assign NaN, get zero

2006-11-11 Thread Keith Goodman
On 11/11/06, Stefan van der Walt [EMAIL PROTECTED] wrote: On Sat, Nov 11, 2006 at 10:40:22AM -0800, Keith Goodman wrote: I accidentally wrote a unit test using int32 instead of float64 and ran into this problem: x = M.matrix([[1, 2, 3]]) x[0,1] = M.nan x matrix([[1, 0, 3

[Numpy-discussion] x.min() depends on ordering

2006-11-11 Thread Keith Goodman
x.min() and x.max() depend on the ordering of the elements: x = M.matrix([[ M.nan, 2.0, 1.0]]) x.min() nan x = M.matrix([[ 1.0, 2.0, M.nan]]) x.min() 1.0 If I were to try the latter in ipython, I'd assume, great, min() ignores NaNs. But then the former would be a bug in my program. Is this

Re: [Numpy-discussion] x.min() depends on ordering

2006-11-11 Thread Keith Goodman
On 11/11/06, Robert Kern [EMAIL PROTECTED] wrote: Barring a clever solution (at least cleverer than I feel like being immediately), the way to solve this would be to check for nans in the array and deal with them separately (or simply ignore them in the case of x.min()). However, this

Re: [Numpy-discussion] x.min() depends on ordering

2006-11-11 Thread Keith Goodman
On 11/11/06, Robert Kern [EMAIL PROTECTED] wrote: Keith Goodman wrote: How about a nanmin() function? Already there. In [2]: nanmin? Type: function Base Class: type 'function' Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/2.5/lib

Re: [Numpy-discussion] Equivalent to list.index ?

2006-11-12 Thread Keith Goodman
On 11/12/06, George Sakkis [EMAIL PROTECTED] wrote: This must be pretty trivial but I couldn't find it in the docs: what's the numpythonic way to find the (first) index of an element, i.e. the equivalent to list.index ? Does where work?

[Numpy-discussion] I can slice but I can't assign

2006-11-12 Thread Keith Goodman
x = M.matrix([[1, 2], [3, 4]]) x matrix([[1, 2], [3, 4]]) y = M.matrix([[5], [6]]) y matrix([[5], [6]]) idx = M.where(x[:,0].A 100)[0] idx array([0, 1]) x[idx,0] # This works matrix([[1], [3]]) x[idx,0] = y# But this doesn't work. How can I

Re: [Numpy-discussion] I can slice but I can't assign

2006-11-12 Thread Keith Goodman
On 11/12/06, Keith Goodman [EMAIL PROTECTED] wrote: x = M.matrix([[1, 2], [3, 4]]) x matrix([[1, 2], [3, 4]]) y = M.matrix([[5], [6]]) y matrix([[5], [6]]) idx = M.where(x[:,0].A 100)[0] idx array([0, 1]) x[idx,0] # This works matrix([[1

[Numpy-discussion] Could numpy.matlib.nanmax return a matrix?

2006-11-12 Thread Keith Goodman
Is anybody interested in making x.max() and nanmax() behave the same for matrices, except for the NaN part? That is, make numpy.matlib.nanmax return a matrix instead of an array. Example = import numpy.matlib as M x = M.rand(3,2) x.max(0) matrix([[ 0.91749823, 0.94942954]])

Re: [Numpy-discussion] List migration

2006-11-14 Thread Keith Goodman
On 11/14/06, Jeff Strunk [EMAIL PROTECTED] wrote: Good afternoon, We will be performing the migration of this mailing list from Sourceforge to SciPy on Thursday at 2pm central. After this time, the new mailing list address will be [EMAIL PROTECTED] . Any mail sent to the Sourceforge address

Re: [Numpy-discussion] mysql - record array

2006-11-14 Thread Keith Goodman
On 11/14/06, Erin Sheldon [EMAIL PROTECTED] wrote: As an aside, your database is running on a local disk, right, so the overehead of retrieving data is minimized here? For my tests I think I am data retrieval limited because I get exactly the same time for the equivalent of retrieve1 and