[Numpy-discussion] array multiplication with different dtypes

2007-03-25 Thread Jan Strube
I'm having a difficult time understanding the following behavior: import numpy as N # create a new array 4 rows, 3 columns x = N.random.random((4, 3)) # elementwise multiplication x*x newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)]) # interpret the array as an array of

[Numpy-discussion] dtype confusion

2007-03-25 Thread Jan Strube
There seems to be a fundamental lack of understanding on my behalf when it comes to dtypes and record arrays. Please consider the following snippet: import numpy as N newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)]) a = N.random.random((100,3)) a.dtype=newtype b = N.colum

Re: [Numpy-discussion] dtype confusion

2007-03-25 Thread Stefan van der Walt
On Sun, Mar 25, 2007 at 04:09:11AM -0700, Jan Strube wrote: > There seems to be a fundamental lack of understanding on my behalf when it > comes to dtypes and record arrays. > Please consider the following snippet: > > import numpy as N > newtype = N.dtype([('x', N.float64 ), ('y', N.float64), ('z

Re: [Numpy-discussion] Detect subclass of ndarray

2007-03-25 Thread Colin J. Williams
Alan G Isaac wrote: > On Sat, 24 Mar 2007, Charles R Harris apparently wrote: >> Yes, that is what I am thinking. Given that there are only the two >> possibilities, row or column, choose the only one that is compatible with >> the multiplying matrix. The result will not always be a column vecto

Re: [Numpy-discussion] Detect subclass of ndarray

2007-03-25 Thread Colin J. Williams
Colin J. Williams wrote: > Alan G Isaac wrote: >> On Sat, 24 Mar 2007, Charles R Harris apparently wrote: >>> Yes, that is what I am thinking. Given that there are only the two >>> possibilities, row or column, choose the only one that is compatible with >>> the multiplying matrix. The result wi

Re: [Numpy-discussion] Simple multi-arg wrapper for dot()

2007-03-25 Thread Colin J. Williams
Bill Baxter wrote: > On 3/25/07, Robert Kern <[EMAIL PROTECTED]> wrote: >> Bill Baxter wrote: > >> I don't know. Given our previous history with convenience functions with >> different calling semantics (anyone remember rand()?), I think it probably >> will >> confuse some people. >> >> I'd reall

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Colin J. Williams
Charles R Harris wrote: > > > On 3/24/07, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > Every so often the idea of new operators comes up because of the need to > do both "matrix-multiplication" and element-by-element multiplication. > > I think this

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread dpn
With the possible inclusion of generic functions in py3k I dont really see the point of adding more operators. (While i do miss mat1 x mat2 from PDL). mat3 = mat1.mm(mat2) or the like seems to be sufficient. I find matrix multiplication annoying in the case of SVD reconstruction: final = matrixm

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Paulo Jose da Silva e Silva
Em Seg, 2007-03-26 às 01:08 +1000, dpn escreveu: > With the possible inclusion of generic functions in py3k I dont really > see the point of adding more operators. (While i do miss mat1 x mat2 > from PDL). > > mat3 = mat1.mm(mat2) or the like seems to be sufficient. > > I find matrix multiplicati

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Alan G Isaac
On Sun, 25 Mar 2007, Paulo Jose da Silva e Silva apparently wrote: > Even though I can get used with using dot (or > matrixmultiply) to do it, I can easily see the benefit of > having a special operator here. Some newer languages are taking advantage of the expressiveness of Unicode for math

Re: [Numpy-discussion] array multiplication with different dtypes

2007-03-25 Thread Travis Oliphant
Jan Strube wrote: > I'm having a difficult time understanding the following behavior: > > import numpy as N > # create a new array 4 rows, 3 columns > x = N.random.random((4, 3)) > # elementwise multiplication > x*x > > newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)]) > > #

[Numpy-discussion] matrix indexing question

2007-03-25 Thread Alan G Isaac
One thing keeps bugging me when I use numpy.matrix. All this is fine:: >>> x=N.mat('1 1;1 0') >>> x matrix([[1, 1], [1, 0]]) >>> x[1,:] matrix([[1, 0]]) But it seems to me that I should be able to extract a matrix row as an array. So this :: >>> x[1] matr

[Numpy-discussion] header file location upon installation

2007-03-25 Thread Daniel Wheeler
Hi, Should the header files in .../lib/python2.4/site-packages/python/numpy/core/include/ be copied to .../include/python2.4/numpy/ upon installation of numpy? As far as I can tell this is not happening. Just wondering what the default behavior should be. Thanks -- Daniel Whe

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Paulo Jose da Silva e Silva
Em Dom, 2007-03-25 às 13:07 -0400, Alan G Isaac escreveu: > So this :: > > >>> x[1] > matrix([[1, 0]]) > > feels wrong. (Similarly when iterating across rows.) > Of course I realize that I can just :: > > >>> x.A[1] > array([1, 0]) > > but since the above keeps feeling wrong I

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Alan G Isaac
> Em Dom, 2007-03-25 às 13:07 -0400, Alan G Isaac escreveu: >> >>> x[1] >> matrix([[1, 0]]) >> feels wrong. (Similarly when iterating across rows.) On Sun, 25 Mar 2007, Paulo Jose da Silva e Silva apparently wrote: > I think the point here is that if you are using matrices, > then all y

[Numpy-discussion] subversion site down

2007-03-25 Thread Christopher Hanley
Hi, It appears that the subversion server is down for numpy. Chris ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Joe Harrington
I strongly agree with the need for different infix operators for matrix and array multiplication. In IDL, I have used both in the same code. IDL uses * for array and # for matrix (hey, # even *looks* like a matrix, very intuitive). It uses ## for right-multiply (why people don't just M-t the var

Re: [Numpy-discussion] dtype confusion

2007-03-25 Thread Jan Strube
Thanks Stefan and Travis for their explanations. First a request: Could both explanations be added to the manual, please? Thanks. So the problem I was having was that I thought this difference in behavior would be caused by two different types: recarray and ndarray. I feel that there is still som

Re: [Numpy-discussion] defmatrix.py

2007-03-25 Thread Charles R Harris
On 3/25/07, Nils Wagner <[EMAIL PROTECTED]> wrote: Hi, Several tests didn't pass due to the recent changes in defmatrix.py. Nils == ERROR: check_matmat (scipy.sparse.tests.test_sparse.test_csc) ---

Re: [Numpy-discussion] Simple multi-arg wrapper for dot()

2007-03-25 Thread Bill Baxter
On 3/25/07, Colin J. Williams <[EMAIL PROTECTED]> wrote: > Bill Baxter wrote: > > On 3/25/07, Robert Kern <[EMAIL PROTECTED]> wrote: > >> Bill Baxter wrote: > > > >> I don't know. Given our previous history with convenience functions with > >> different calling semantics (anyone remember rand()?),

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Bill Baxter
On 3/26/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: > > Em Dom, 2007-03-25 às 13:07 -0400, Alan G Isaac escreveu: > >> >>> x[1] > >> matrix([[1, 0]]) > >> feels wrong. (Similarly when iterating across rows.) > > > On Sun, 25 Mar 2007, Paulo Jose da Silva e Silva apparently wrote: > > I thi

Re: [Numpy-discussion] header file location upon installation

2007-03-25 Thread Robert Kern
Daniel Wheeler wrote: > Hi, > > Should the header files in > > .../lib/python2.4/site-packages/python/numpy/core/include/ > > be copied to > >.../include/python2.4/numpy/ > > upon installation of numpy? No. For reasons that we've discussed several times here, the only reliabl

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Colin J. Williams
Alan G Isaac wrote: > One thing keeps bugging me when I use numpy.matrix. > > All this is fine:: > > >>> x=N.mat('1 1;1 0') > >>> x > matrix([[1, 1], > [1, 0]]) > >>> x[1,:] > matrix([[1, 0]]) > > But it seems to me that I should be able > to extract a matrix row

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Steven H. Rogers
Joe Harrington wrote: > > On the other hand, Python, IDL, and Matlab are attractive to us mainly > because their syntaxes allow us to see the math, understand it on > inspection, and verify its correctness. The math we write in these > languages looks as much like the math we do on paper as ASCII

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Colin J. Williams
Alan G Isaac wrote: >> Em Dom, 2007-03-25 Ã s 13:07 -0400, Alan G Isaac escreveu: >>> >>> x[1] >>> matrix([[1, 0]]) >>> feels wrong. (Similarly when iterating across rows.) > > > On Sun, 25 Mar 2007, Paulo Jose da Silva e Silva apparently wrote: >> I think the point here is that if you a

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Colin J. Williams
Bill Baxter wrote: > On 3/26/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: >>> Em Dom, 2007-03-25 às 13:07 -0400, Alan G Isaac escreveu: >>> x[1] matrix([[1, 0]]) feels wrong. (Similarly when iterating across rows.) >> >> On Sun, 25 Mar 2007, Paulo Jose da Silva e Silva appare

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Bill Baxter
On 3/26/07, Steven H. Rogers <[EMAIL PROTECTED]> wrote: > Joe Harrington wrote: > > > > On the other hand, Python, IDL, and Matlab are attractive to us mainly > > because their syntaxes allow us to see the math, understand it on > > inspection, and verify its correctness. The math we write in thes

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Bill Baxter
On 3/26/07, Colin J. Williams <[EMAIL PROTECTED]> wrote: > Bill Baxter wrote: > > This may sound silly, but I really think seeing all those brackets is > > what makes it feel wrong. Matlab's output doesn't put it in your > > face that your 4 is really a matrix([[4]]), even though that's what it

Re: [Numpy-discussion] defmatrix.py

2007-03-25 Thread Charles R Harris
On 3/25/07, Nils Wagner <[EMAIL PROTECTED]> wrote: Hi, BTW, I can't import scipy.sparse, I get the following error: ImportError: cannot import name densetocsr What am I doing wrong? Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Charles R Harris
On 3/25/07, Bill Baxter <[EMAIL PROTECTED]> wrote: On 3/26/07, Steven H. Rogers <[EMAIL PROTECTED]> wrote: > Joe Harrington wrote: > > > > On the other hand, Python, IDL, and Matlab are attractive to us mainly > > because their syntaxes allow us to see the math, understand it on > > inspection,

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Alan G Isaac
> Alan G Isaac wrote: >> So this :: >> >>> x[1] >> matrix([[1, 0]]) >> feels wrong. (Similarly when iterating across rows.) >> Of course I realize that I can just :: >> >>> x.A[1] >> array([1, 0]) On Sun, 25 Mar 2007, "Colin J. Williams" apparently wrote: > An array and

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Alan G Isaac
> On 3/26/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: >> finds itself in basic conflict with the idea that I ought >> to be able to iterate over the objects in an iterable >> container. >> I mean really, does this not "feel" wrong? :: >> >>> for item in x: print item.__repr__() >> .

Re: [Numpy-discussion] subversion site down

2007-03-25 Thread Jeff Strunk
Thank you for letting me know. I restarted the server at 5:30pm central. -Jeff On Sunday 25 March 2007 1:42 pm, Christopher Hanley wrote: > Hi, > > It appears that the subversion server is down for numpy. > > Chris ___ Numpy-discussion mailing list Nump

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Steven H. Rogers
Bill Baxter wrote: > > Until we get to the point that it's actually harder to find a > non-Unicode console/editor than a Unicode one, I think the idea of > using Unicode symbols as part of the syntax of a general purpose > language is a bad one. Given that most editors lack good Unicode support,

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread Bill Baxter
On 3/26/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > What might work better is simply some sort of sign that causes a function to > be parsed as infix, x @dot y for instance, although Python already uses @ > for other things. I don't know what symbols are left unused at this point, > maybe !

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Bill Baxter
On 3/26/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: > > On 3/26/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: > >> finds itself in basic conflict with the idea that I ought > >> to be able to iterate over the objects in an iterable > >> container. > > >> I mean really, does this not "feel" wrong? ::

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Alan G Isaac
>> On 3/26/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: >>> finds itself in basic conflict with the idea that >>> I ought to be able to iterate over the objects in an >>> iterable container. I mean really, does this not "feel" >>> wrong? :: >>> for item in x: print item.__repr__() >>> .

Re: [Numpy-discussion] matrix indexing question

2007-03-25 Thread Alan G Isaac
Oooops, they should match of course. :: >>> X[1] array([3,4]) >>> X[1,:] matrix([[3, 4]]) But again the point is: indexing for submatrices should produce matrices. Normal Python indexing should access the constituent arrays. Cheers, Alan Isaac _

Re: [Numpy-discussion] New Operators in Python

2007-03-25 Thread dmitrey
Hallo! 1)Isn't it possible to add .A & .M attributes to the array & matrix instances? I would find them very useful for some cases more convenient than asarray() or mat(). Let x.A just do nothing if x is array and x.M do nothing if x i matrix. 2)And if y=flat(x), what about y.R and y.C for to