[Numpy-discussion] iterate over multiple arrays

2011-09-11 Thread David Froger
Hy everybody, I'm wondering what is the (best) way to apply the same function to multiple arrays. For example, in the following code: from numpy import * def f(arr): return arr*2 a = array( [1,1,1] ) b = array( [2,2,2] ) c = array( [3,3,3] ) d = array( [4,4,4] ) a = f(a) b = f(b) c = f(c

Re: [Numpy-discussion] recarrays and lists of lists

2011-09-11 Thread Robert Kern
On Sun, Sep 11, 2011 at 14:44, Travis Vaught wrote: > > On Sep 11, 2011, at 2:58 AM, Robert Kern wrote: > >> On Sun, Sep 11, 2011 at 00:30, Travis Vaught wrote: >>> Greetings, >>> >>> Is there a particular reason why a list of lists can't be passed in to >>> create a recarray given a particular

Re: [Numpy-discussion] recarrays and lists of lists

2011-09-11 Thread Travis Vaught
On Sep 11, 2011, at 2:58 AM, Robert Kern wrote: > On Sun, Sep 11, 2011 at 00:30, Travis Vaught wrote: >> Greetings, >> >> Is there a particular reason why a list of lists can't be passed in to >> create a recarray given a particular dtype? >> >> A list of tuples works fine. I keep getting bi

Re: [Numpy-discussion] How to apply Numpy ufunc to Scipy sparse matrices?

2011-09-11 Thread Pengkui Luo
On Sun, Sep 11, 2011 at 13:23, Pauli Virtanen wrote: > Sun, 11 Sep 2011 03:03:26 -0500, Pengkui Luo wrote: > [clip] > > However, converting a large sparse matrix to dense would easily eat up > > the memory. Is there a way for np.sign (as well as other ufunc) to take > > a sparse matrix as paramet

Re: [Numpy-discussion] How to apply Numpy ufunc to Scipy sparse matrices?

2011-09-11 Thread Pauli Virtanen
Sun, 11 Sep 2011 03:03:26 -0500, Pengkui Luo wrote: [clip] > However, converting a large sparse matrix to dense would easily eat up > the memory. Is there a way for np.sign (as well as other ufunc) to take > a sparse matrix as parameter, and return a sparse matrix? For CSR, CSC, and DIA you can do

[Numpy-discussion] [ANN] ESCO2012 and PyHPC2011: Python in science in major computational science conference

2011-09-11 Thread Gael Varoquaux
ESCO 2012 - European Seminar on Coupled Problems = ESCO2012 http://esco2012.femhub.com/ is the 3rd event in a series of interdisciplineary meetings dedicated to computational science challenges in multi-physics and PDEs. I was invited as ESCO last y

[Numpy-discussion] How to apply Numpy ufunc to Scipy sparse matrices?

2011-09-11 Thread Pengkui Luo
It seems that numpy universal functions only apply to ndarray (or dense matrix). Is there a way to apply them to scipy sparse matrices also? For example, suppose S is an large sparse matrix (lil_matrix format, dtype=np.float). I want to get another sparse matrix B (of the same shape) that represen

Re: [Numpy-discussion] recarrays and lists of lists

2011-09-11 Thread Robert Kern
On Sun, Sep 11, 2011 at 00:30, Travis Vaught wrote: > Greetings, > > Is there a particular reason why a list of lists can't be passed in to create > a recarray given a particular dtype? > > A list of tuples works fine.  I keep getting bitten by this and was thinking > it should be an easy check/