Re: [Numpy-discussion] Using __complex__ for complex dtype

2009-07-10 Thread Robert Bradshaw
Nevermind, I just found http://bugs.python.org/issue1675423 . On Jul 9, 2009, at 1:41 AM, Robert Bradshaw wrote: I know using __complex__ has been discussed before, but it would be really nice if it were at least used to convert object to the complex dtypes. - Robert In [1]: class

Re: [Numpy-discussion] Even Sphere Volume

2009-07-10 Thread Markus Rosenstihl
Here is a different one, based on the ZCW (Zaremba, Conroy, Wolfsberg) algorithm used for powder spectra to equally distribute points over a sphere surface: This paper gives an nice overview (I think I took the actual algorithm from there): Computer simulations in solid-state NMR. III.

Re: [Numpy-discussion] an np.arange for arrays?

2009-07-10 Thread David Warde-Farley
On 10-Jul-09, at 1:25 AM, Chris Colbert wrote: actually what would be better is if i can pass two 1d arrays X and Y both size Nx1 and get back a 2d array of size NxM where the [n,:] row is the linear interpolation of X[n] to Y[n] This could be more efficient, but here's a solution using

[Numpy-discussion] np.concatenate and np.column_stack shouldn't they be the same?

2009-07-10 Thread John [H2O]
Can someone explain: x = np.arange(20) y = np.arange(20) z = np.vstack((x,y)).T is equal to: z = np.column_stack((x,y)) but this does not do the same: z = np.concatenate((x,y),axis=0) # or with axis=1 Seems I should be able to use concatenate to make a column stack?? Thanks! -- View

Re: [Numpy-discussion] transform an array of points efficiently?

2009-07-10 Thread Bruce Southey
hey, great man! thanks! I had thought that it may have been possible with a single dot, but how to do it escaped me. Thanks again! Chris Hi, When dot is not what you want, often numpy.inner() and numpy.outer() do what you want. So try using numpy.inner(x,y)...

Re: [Numpy-discussion] an np.arange for arrays?

2009-07-10 Thread Chris Colbert
Oh cool, I couldn't figure out with mgrid. here's what ended up with using broadcasting: import numpy as np X = np.zeros((10)) Y = np.arange(10, 20) M = 10 increments = np.arange(1, M+1) delta = Y - X dl = (delta / M).reshape(-1, 1) interps = dl * increments lines = X + interps lines

[Numpy-discussion] speed up np.diag

2009-07-10 Thread Citi, Luca
Hello, I happened to have a look at the code for np.diag and found it more complicated that necessary. I think it can be rewritten more cleanly and efficiently. Appended you can find both versions. The speed improvement is significant: In [145]: x = S.rand(1000,1300) In [146]: assert

Re: [Numpy-discussion] speed up np.diag

2009-07-10 Thread Pauli Virtanen
Fri, 10 Jul 2009 15:55:58 +0100, Citi, Luca kirjoitti: [clip] ## SUGGESTED def diag(v, k=0): v = asarray(v) s = v.shape if len(s) == 1: [clip] elif len(s) == 2: if v.flags.f_contiguous: v, k, s = v.T, -k, s[::-1] Is this correct? The .flat iterator

[Numpy-discussion] numpy for 2.6 on mac os x

2009-07-10 Thread Tommy Grav
The current dmg on the numpy download pages is buildt against 2.5. Is there any plans to make one for 2.6 or do I have to compile from the source? Cheers Tommy ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] speed up np.diag

2009-07-10 Thread Citi, Luca
if v.flags.f_contiguous: v, k, s = v.T, -k, s[::-1] Is this correct? The .flat iterator always traverses the array in virtual C-order, not in the order it's laid out in memory. The code could work (and gives the same results) even without the two lines above which in

Re: [Numpy-discussion] np.concatenate and np.column_stack shouldn't they be the same?

2009-07-10 Thread Robert Kern
On Fri, Jul 10, 2009 at 07:40, John [H2O]washa...@gmail.com wrote: Can someone explain: x = np.arange(20) y = np.arange(20) z = np.vstack((x,y)).T is equal to: z = np.column_stack((x,y)) but this does not do the same: z = np.concatenate((x,y),axis=0)  # or with axis=1 Seems I

Re: [Numpy-discussion] speeding up an array operation

2009-07-10 Thread Frédéric Bastien
Can you do it by chunk instead of by row? If the chunk is not too big the sort could be faster then the access to the multiple dictionnary access. But don't forget, you change an algo of O(n), by O(nlogn) with a lower constant. So the n should not be too big. Just try different value. Frédéric

Re: [Numpy-discussion] an np.arange for arrays?

2009-07-10 Thread David Warde-Farley
On 10-Jul-09, at 1:26 PM, David Goldsmith wrote: grid = np.array([np.linspace(x[i],y[i],nrows) for i in range(len(x))]).T Indeed, linspace will work, but careful with Python loops though, it'll be 2x to 6x slower (based on my empirical fiddling) than the solution involving mgrid. In

Re: [Numpy-discussion] an np.arange for arrays?

2009-07-10 Thread David Goldsmith
Touche. DG --- On Fri, 7/10/09, David Warde-Farley d...@cs.toronto.edu wrote: From: David Warde-Farley d...@cs.toronto.edu Subject: Re: [Numpy-discussion] an np.arange for arrays? To: Discussion of Numerical Python numpy-discussion@scipy.org Date: Friday, July 10, 2009, 1:06 PM On

Re: [Numpy-discussion] Even Sphere Volume

2009-07-10 Thread Ian Mallett
These are all great algorithms, thanks for the help! ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Using __complex__ for complex dtype

2009-07-10 Thread Lisandro Dalcin
On Fri, Jul 10, 2009 at 3:52 AM, Robert Bradshawrober...@math.washington.edu wrote: Nevermind, I just found http://bugs.python.org/issue1675423 . Nevermind? Perhaps NumPy should handle this gotcha for Python 2.6 ? - On Jul 9, 2009, at 1:41 AM, Robert Bradshaw wrote: I know using

Re: [Numpy-discussion] numpy for 2.6 on mac os x

2009-07-10 Thread David Cournapeau
On Sat, Jul 11, 2009 at 12:19 AM, Tommy Gravtg...@mac.com wrote: The current dmg on the numpy download pages is buildt against 2.5. Is there any plans to make one for 2.6 or do I have to compile from the source? There are plans :) I am building the 0.7.1 binaries right now, and mac os x

Re: [Numpy-discussion] speeding up an array operation

2009-07-10 Thread Mag Gam
Hey Frederic: thanks for the response. I really want it to do it your way but I am a bad programmer. Do you have any sample code? your method seems correct 2009/7/10 Frédéric Bastien no...@nouiz.org: Can you do it by chunk instead of by row? If the chunk is not too big the sort could be