You can subscribe to this list here.
2000 |
Jan
(8) |
Feb
(49) |
Mar
(48) |
Apr
(28) |
May
(37) |
Jun
(28) |
Jul
(16) |
Aug
(16) |
Sep
(44) |
Oct
(61) |
Nov
(31) |
Dec
(24) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(56) |
Feb
(54) |
Mar
(41) |
Apr
(71) |
May
(48) |
Jun
(32) |
Jul
(53) |
Aug
(91) |
Sep
(56) |
Oct
(33) |
Nov
(81) |
Dec
(54) |
2002 |
Jan
(72) |
Feb
(37) |
Mar
(126) |
Apr
(62) |
May
(34) |
Jun
(124) |
Jul
(36) |
Aug
(34) |
Sep
(60) |
Oct
(37) |
Nov
(23) |
Dec
(104) |
2003 |
Jan
(110) |
Feb
(73) |
Mar
(42) |
Apr
(8) |
May
(76) |
Jun
(14) |
Jul
(52) |
Aug
(26) |
Sep
(108) |
Oct
(82) |
Nov
(89) |
Dec
(94) |
2004 |
Jan
(117) |
Feb
(86) |
Mar
(75) |
Apr
(55) |
May
(75) |
Jun
(160) |
Jul
(152) |
Aug
(86) |
Sep
(75) |
Oct
(134) |
Nov
(62) |
Dec
(60) |
2005 |
Jan
(187) |
Feb
(318) |
Mar
(296) |
Apr
(205) |
May
(84) |
Jun
(63) |
Jul
(122) |
Aug
(59) |
Sep
(66) |
Oct
(148) |
Nov
(120) |
Dec
(70) |
2006 |
Jan
(460) |
Feb
(683) |
Mar
(589) |
Apr
(559) |
May
(445) |
Jun
(712) |
Jul
(815) |
Aug
(663) |
Sep
(559) |
Oct
(930) |
Nov
(373) |
Dec
|
From: Travis O. <oli...@ie...> - 2006-06-02 17:08:46
|
Joris De Ridder wrote: > On Friday 02 June 2006 14:58, Eric Jonas wrote: > [EJ]: Hello! I've been using numeric for a while, and the recent list traffic > [EJ]: prompted me to finally migrate all my old code. On a whim, we were > [EJ]: benchmarking numpy vs numeric and have been lead to the conclusion that > [EJ]: numpy is at least 50x slower; a 1000x1000 matmul takes 16 sec in numpy > [EJ]: but 300 ms in numeric. > > You mean the other way around? > > I also tested numpy vs numarray, and numarray seems to be roughly 3 times > faster than numpy for your particular testcase. > Please post your test cases. We are trying to remove any slowness, but need testers to do it. -Travis |
From: Travis O. <oli...@ie...> - 2006-06-02 17:07:40
|
Robert Kern wrote: > Filip Wasilewski wrote: > > >> So the next question is what's the difference between matrixmultiply and >> dot in NumPy? >> > > matrixmultiply is a deprecated compatibility name. Always use dot. dot will get > replaced with the optimized dotblas implementation when an optimized BLAS is > available. matrixmultiply will not (probably not intentionally, but I'm happy > with the current situation). > It's true that matrixmultiply has been deprecated for some time (at least 8 years...) The basic dot function gets over-written with a BLAS-optimized version but the matrixmultiply does not get changed. So replace matrixmultiply with dot. It wasn't an intentional thing, but perhaps it will finally encourage people to always use dot. -Travis |
From: Christopher B. <Chr...@no...> - 2006-06-02 16:57:29
|
Robert Kern wrote: >> As I need Numeric and numarray compatibility at this point, it seems the > Ah. It might help if you said that up front. Yes, it would, but that would mean accepting that I need to keep backward compatibility -- I'm still hoping! > x = arange(minx, maxx+step, step) # oy. > y = arange(miny, maxy+step, step) > > nx = len(x) > ny = len(y) > > x = repeat(x, ny) > y = concatenate([y] * nx) > points = transpose([x, y]) Somehow I never think to use repeat. And why use repeat for x and concatenate for y? Rob Hooft wrote: > How about something like: > > >>> k=Numeric.repeat(range(0,5+1),Numeric.ones(6)*7) > >>> l=Numeric.resize(range(0,6+1),[42]) > >>> > zone=Numeric.concatenate((k[:,Numeric.NewAxis],l[:,Numeric.NewAxis]),axis=1) > This is the same speed as Robert Kern's solution for large arrays, a bit > slower for small arrays. Both are a little faster than yours. Did you time them? And yours only handles integers. This is my timing: For small arrays: Using numpy The Numpy way took: 0.020000 seconds My way took: 0.010000 seconds Robert's way took: 0.020000 seconds Using Numeric My way took: 0.010000 seconds Robert's way took: 0.020000 seconds Using numarray My way took: 0.070000 seconds Robert's way took: 0.120000 seconds Number of X: 4 Number of Y: 3 So my way was faster with all three packages for small arrays. For Medium arrays ( the size I'm most likely to be using ): Using numpy The Numpy way took: 0.120000 seconds My way took: 0.040000 seconds Robert's way took: 0.030000 seconds Using Numeric My way took: 0.040000 seconds Robert's way took: 0.030000 seconds Using numarray My way took: 0.090000 seconds Robert's way took: 1.070000 seconds Number of X: 21 Number of Y: 41 Now we're getting close, with mine faster with numarray, but Robert's faster with Numeric and numpy. For Large arrays: (still not very big, but as big as I'm likely to need) Using numpy The Numpy way took: 4.200000 seconds My way took: 0.660000 seconds Robert's way took: 0.340000 seconds Using Numeric My way took: 0.590000 seconds Robert's way took: 0.500000 seconds Using numarray My way took: 0.390000 seconds Robert's way took: 20.340000 seconds Number of X: 201 Number of Y: 241 So Robert's way still is faster with Numeric and numpy, but Much slower with numarray. As it's close with numpy and Numeric, but mine is much faster with numarray, I think I'll stick with mine. I note that while the numpy way, using mgrid(), is nice and clean to write, it is slower across the board. Perhaps mgrid(0 could use some optimization. This is exactly why I had suggested that one thing I wanted for numpy was an as-easy-to-use-as-possible C/C++ API. It would be nice to be able to write as many as possible of these kinds of utility functions in C as we could. In case anyone is interested, I'm using this to draw a grid of dots on the screen for my wxPython FloatCanvas. Every time the image is changed or moved or zoomed, I need to re-calculate the points before drawing them, so it's nice to have it fast. I've enclosed my test code. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: Robert K. <rob...@gm...> - 2006-06-02 16:20:15
|
Filip Wasilewski wrote: > So the next question is what's the difference between matrixmultiply and > dot in NumPy? matrixmultiply is a deprecated compatibility name. Always use dot. dot will get replaced with the optimized dotblas implementation when an optimized BLAS is available. matrixmultiply will not (probably not intentionally, but I'm happy with the current situation). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Robert K. <rob...@gm...> - 2006-06-02 16:17:06
|
Sven Schreiber wrote: > Hi all, > this may be a stupid question, but why doesn't rand accept a shape tuple > as argument? I find the difference between the argument types of rand > and (for example) zeros somewhat confusing. (See below for > illustration.) Can anybody offer an intuition/explanation? rand() is a convenience function. It's only purpose is to offer this convenient API. If you want a function that takes tuples, use numpy.random.random(). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Robert K. <rob...@gm...> - 2006-06-02 16:09:44
|
r.d...@ti... wrote: > Hi, > > maybe is not what you meant, but presently I'm looking for a sparse > eigenvalue solver. As far as I've understood the ARPACK bindings are > still missing. This library is one of the most used, so I think it > would be very useful to have integrated in numpy. No, that isn't what he meant. He wants to help projects that are currently using Numeric and numarray convert to numpy. In any case, ARPACK certainly won't go into numpy. It might go into scipy if you are willing to contribute wrappers for it. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Sven S. <sve...@gm...> - 2006-06-02 15:39:05
|
Hi all, this may be a stupid question, but why doesn't rand accept a shape tuple as argument? I find the difference between the argument types of rand and (for example) zeros somewhat confusing. (See below for illustration.) Can anybody offer an intuition/explanation? (This is still on 0.9.6 because of matplotlib compatibility.) Thanks much, Sven >>> import numpy as n >>> n.rand((3,2)) Traceback (most recent call last): File "<interactive input>", line 1, in ? File "mtrand.pyx", line 433, in mtrand.RandomState.rand File "mtrand.pyx", line 361, in mtrand.RandomState.random_sample File "mtrand.pyx", line 131, in mtrand.cont0_array TypeError: an integer is required >>> n.zeros((3,2)) array([[0, 0], [0, 0], [0, 0]]) >>> n.zeros(3,2) Traceback (most recent call last): File "<interactive input>", line 1, in ? TypeError: data type not understood >>> n.rand(3,2) array([[ 0.27017528, 0.98280906], [ 0.58592731, 0.63706962], [ 0.74705193, 0.65980377]]) >>> |
From: RayS <ra...@bl...> - 2006-06-02 14:27:36
|
favorable numpy creates arrays much faster, fft seems a tad faster a useful metric, I think, for O-scope and ADC apps I get 0.0039054614015815738 0.0019759541205486885 0.023268623246481726 0.0023570392204637913 from the below on a PIII 600... from time import * n=4096 r = range(n) #numpy import numpy arr = numpy.array # array creation t0 = clock() for i in r: a = arr(r) (clock()-t0)/float(n) #fft of n fftn = numpy.fft t0 = clock() for i in r: f = fftn(a) (clock()-t0)/float(n) #Numeric import Numeric arr = Numeric.array # array creation t0 = clock() for i in r: a = arr(r) (clock()-t0)/float(n) #fft of n from FFT import * t0 = clock() for i in r: f = fft(a) (clock()-t0)/float(n) |
From: George N. <gn...@go...> - 2006-06-02 14:17:06
|
Yes, using numpy.dot I get 250ms, numpy.matrixmultiply 11.8s. while a sans-BLAS Numeric.matrixmultiply takes 12s. The first 100 results from numpy.dot and numpy.matrixmultiply are identical .... Use dot;) --George. On 02/06/06, Filip Wasilewski <fi...@ft...> wrote: > Hi, > > It seems that in Numeric the matrixmultiply is alias for dot function, > which "uses the BLAS optimized routines where possible", as the help() > says. > > In NumPy (0.9.6, not upgraded yet to 0.9.8), the matrixmultiply is a > function of numpy.core.multiarray, while dot refers to > numpy.core._dotblas. > > On my system the timings and results with numpy.dot are quite similar > to that with Numeric.matrixmultiply. > > So the next question is what's the difference between matrixmultiply and > dot in NumPy? > > Filip > > > > Hello! I've been using numeric for a while, and the recent list traffic > > prompted me to finally migrate all my old code. On a whim, we were > > benchmarking numpy vs numeric and have been lead to the conclusion that > > numpy is at least 50x slower; a 1000x1000 matmul takes 16 sec in numpy > > but 300 ms in numeric. > > > Now, of course, I don't believe this, but I can't figure out what we're > > doing wrong; I'm not the only person who has looked at this code, so can > > anyone tell me what we're doing wrong? > > > > > > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |
From: Filip W. <fi...@ft...> - 2006-06-02 13:48:46
|
Hi, It seems that in Numeric the matrixmultiply is alias for dot function, which "uses the BLAS optimized routines where possible", as the help() says. In NumPy (0.9.6, not upgraded yet to 0.9.8), the matrixmultiply is a function of numpy.core.multiarray, while dot refers to numpy.core._dotblas. On my system the timings and results with numpy.dot are quite similar to that with Numeric.matrixmultiply. So the next question is what's the difference between matrixmultiply and dot in NumPy? Filip > Hello! I've been using numeric for a while, and the recent list traffic > prompted me to finally migrate all my old code. On a whim, we were > benchmarking numpy vs numeric and have been lead to the conclusion that > numpy is at least 50x slower; a 1000x1000 matmul takes 16 sec in numpy > but 300 ms in numeric. > Now, of course, I don't believe this, but I can't figure out what we're > doing wrong; I'm not the only person who has looked at this code, so can > anyone tell me what we're doing wrong? |
From: Eric J. <jo...@mw...> - 2006-06-02 13:34:46
|
I meant "numeric is slower than numpy", that is, modern numpy (0.9.8) appears to lose out majorly to numeric. This doesn't make much sense, so I figured there was something wrong with my benchmark, or my numpy install, and wanted to check if others had seen this sort of behavior. ...Eric On Fri, 2006-06-02 at 15:27 +0200, Joris De Ridder wrote: > > On Friday 02 June 2006 14:58, Eric Jonas wrote: > [EJ]: Hello! I've been using numeric for a while, and the recent list traffic > [EJ]: prompted me to finally migrate all my old code. On a whim, we were > [EJ]: benchmarking numpy vs numeric and have been lead to the conclusion that > [EJ]: numpy is at least 50x slower; a 1000x1000 matmul takes 16 sec in numpy > [EJ]: but 300 ms in numeric. > > You mean the other way around? > > I also tested numpy vs numarray, and numarray seems to be roughly 3 times > faster than numpy for your particular testcase. > > J. > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion |
From: Joris De R. <jo...@st...> - 2006-06-02 13:27:24
|
On Friday 02 June 2006 14:58, Eric Jonas wrote: [EJ]: Hello! I've been using numeric for a while, and the recent list traffic [EJ]: prompted me to finally migrate all my old code. On a whim, we were [EJ]: benchmarking numpy vs numeric and have been lead to the conclusion that [EJ]: numpy is at least 50x slower; a 1000x1000 matmul takes 16 sec in numpy [EJ]: but 300 ms in numeric. You mean the other way around? I also tested numpy vs numarray, and numarray seems to be roughly 3 times faster than numpy for your particular testcase. J. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
From: Eric J. <jo...@mw...> - 2006-06-02 12:59:10
|
Hello! I've been using numeric for a while, and the recent list traffic prompted me to finally migrate all my old code. On a whim, we were benchmarking numpy vs numeric and have been lead to the conclusion that numpy is at least 50x slower; a 1000x1000 matmul takes 16 sec in numpy but 300 ms in numeric. Now, of course, I don't believe this, but I can't figure out what we're doing wrong; I'm not the only person who has looked at this code, so can anyone tell me what we're doing wrong? We run both benchmarks twice to try and mitigate any start-up and cache effects. This is with debian-amd64's packaged numeric 24.2-2 and a locally built numpy-0.9.8. /usr/bin/python import time import numpy import random import Numeric def numpytest(): N = 1000 x = numpy.zeros((N,N),'f') y = numpy.zeros((N,N),'f') for i in range(N): for j in range(N): x[i, j] = random.random() y[i, j] = random.random() t1 = time.clock() z = numpy.matrixmultiply(x, y) t2 = time.clock() print (((t2 - t1)*1000)) def numerictest(): N = 1000 x = Numeric.zeros((N,N),'f') y = Numeric.zeros((N,N),'f') for i in range(N): for j in range(N): x[i, j] = random.random() y[i, j] = random.random() t1 = time.clock() z = Numeric.matrixmultiply(x, y) t2 = time.clock() print (((t2 - t1)*1000)) numerictest() numpytest() numpytest() numerictest() on our hardware a call to numerictest() takes 340 ms and a numpytest takes around 13 sec (!). Any advice on what we're doing wrong would be very helpful. ...Eric |
From: <r.d...@ti...> - 2006-06-02 11:54:54
|
Hi, maybe is not what you meant, but presently I'm looking for a sparse=20 eigenvalue solver. As far as I've understood the ARPACK bindings are=20 still missing. This library is one of the most used, so I think it=20 would be very useful to have integrated in numpy. Riccardo =09=09 La gara pi=C3=B9 entusiasmante dell'anno!=20 Gioca e corri alla velocit=C3=A0 della luce sui 18 circuiti di Intel Speed = Contest 2006! I pi=C3=B9 bravi vincono Notebook Sony VAIO, iPod da 60 GB e altro ancora..= .=20 Sfida gli amici! http://intelspeedcontest2006.tiscali.it/=20 =09 |
From: Joris De R. <jo...@st...> - 2006-06-02 11:07:03
|
[CB]: I was reacting to a post a while back that suggested pointing people [CB]: searching for numpy to the main scipy page, which I did not think was a [CB]: good idea. That would be my post :o) The reasons why I suggested this are 1) www.scipy.org is at the moment the most informative site on numpy 2) of all sites www.scipy.org looks currently most professional 3) a wiki-style site where everyone can contribute is really great 4) I like information to be centralized. Having to check pointers, docs and cookbooks on two different sites is inefficient 5) Two different sites inevitably implies some duplication of the work Just as you, I am not (yet) a scipy user, I only have numpy installed at the moment. The principal reason is the same as the one you mentioned. But for me this is an extra motivation to merge scipy.org and numpy.org: 6) merging scipy.org and numpy.org will hopefully lead to a larger SciPy community and this in turn hopefully leads to user-friendly installation procedures. Cheers, Joris Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
From: Rob H. <ro...@ho...> - 2006-06-02 05:31:43
|
Christopher Barker wrote: > x = N.arange(minx, maxx+Spacing, Spacing) # makeing sure to get the last > point > y = N.arange(miny, maxy+Spacing, Spacing) # an extra is OK > points = N.zeros((len(y), len(x), 2), N.Float) > x.shape = (1,-1) > y.shape = (-1,1) > points[:,:,0] += x > points[:,:,1] += y > points.shape = (-1,2) > > print points How about something like: >>> k=Numeric.repeat(range(0,5+1),Numeric.ones(6)*7) >>> l=Numeric.resize(range(0,6+1),[42]) >>> zone=Numeric.concatenate((k[:,Numeric.NewAxis],l[:,Numeric.NewAxis]),axis=1) >>> zone array([[0, 0], [0, 1], [0, 2], ... [5, 4], [5, 5], [5, 6]]) This is the same speed as Robert Kern's solution for large arrays, a bit slower for small arrays. Both are a little faster than yours. Rob -- Rob W.W. Hooft || ro...@ho... || http://www.hooft.net/people/rob/ |
From: Charles R H. <cha...@gm...> - 2006-06-02 05:05:17
|
Tom, The list -- nee tuple, thanks Travis -- is the list of key sequences and each key sequence can be a column in a matrix. So for instance if you wanted to sort on a few columns of a matrix, say columns 2,1, and 0, in that order, and then rearrange the rows so the columns were ordered, you would do something like: >>> a = randint(0,2,(7,4)) >>> a array([[0, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1], [0, 1, 0, 1], [1, 1, 1, 0], [0, 1, 1, 1], [0, 1, 0, 1]]) >>> ind = lexsort((a[:,2],a[:,1],a[:,0])) >>> sorted = a[ind] >>> sorted array([[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 0]]) Note that the last key defines the major order. Chuck On 6/1/06, Tom Denniston <tom...@al...> wrote: > > This function is really useful but it seems to only take tuples not > ndarrays. This seems kinda strange. Does one have to convert the > ndarray into a tuple to use it? This seems extremely inefficient. Is > there an efficient way to argsort a 2d array based upon multiple > columns if lexsort is not the correct way to do this? The only way I > have found to do this is to construct a list of tuples and sort them > using python's list sort. This is inefficient and convoluted so I was > hoping lexsort would provide a simple solution. > > --Tom > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |
From: Travis O. <oli...@ie...> - 2006-06-02 00:52:09
|
Tom Denniston wrote: > This function is really useful but it seems to only take tuples not > ndarrays. This seems kinda strange. Does one have to convert the > ndarray into a tuple to use it? This seems extremely inefficient. Is > there an efficient way to argsort a 2d array based upon multiple > columns if lexsort is not the correct way to do this? The only way I > have found to do this is to construct a list of tuples and sort them > using python's list sort. This is inefficient and convoluted so I was > hoping lexsort would provide a simple solution. > I've just changed lexsort to accept any sequence object as keys. This means that it can now be used to sort a 2d array (of the same data-type) based on multiple rows. The sorting will be so that the last row is sorted with any repeats sorted by the second-to-last row and remaining repeats sorted by the third-to-last row and so forth... The return value is an array of indices. For the 2d example you can use ind = lexsort(a) sorted = a[:,ind] # or a.take(ind,axis=-1) Example: >>> a = array([[1,3,2,2,3,3],[4,5,4,6,4,3]]) >>> ind = lexsort(a) >>> sorted = a.take(ind,axis=-1) >>> sorted array([[3, 1, 2, 3, 3, 2], [3, 4, 4, 4, 5, 6]]) >>> a array([[1, 3, 2, 2, 3, 3], [4, 5, 4, 6, 4, 3]]) -Travis |
From: Tom D. <tom...@al...> - 2006-06-02 00:50:42
|
This is great! Many thanks Travis. I can't wait for the next release! --Tom On 6/1/06, Travis Oliphant <oli...@ie...> wrote: > Tom Denniston wrote: > > This function is really useful but it seems to only take tuples not > > ndarrays. This seems kinda strange. Does one have to convert the > > ndarray into a tuple to use it? This seems extremely inefficient. Is > > there an efficient way to argsort a 2d array based upon multiple > > columns if lexsort is not the correct way to do this? The only way I > > have found to do this is to construct a list of tuples and sort them > > using python's list sort. This is inefficient and convoluted so I was > > hoping lexsort would provide a simple solution. > > > > I've just changed lexsort to accept any sequence object as keys. This > means that it can now be used to sort a 2d array (of the same data-type) > based on multiple rows. The sorting will be so that the last row is > sorted with any repeats sorted by the second-to-last row and remaining > repeats sorted by the third-to-last row and so forth... > > The return value is an array of indices. For the 2d example you can use > > ind = lexsort(a) > sorted = a[:,ind] # or a.take(ind,axis=-1) > > > Example: > > >>> a = array([[1,3,2,2,3,3],[4,5,4,6,4,3]]) > >>> ind = lexsort(a) > >>> sorted = a.take(ind,axis=-1) > >>> sorted > array([[3, 1, 2, 3, 3, 2], > [3, 4, 4, 4, 5, 6]]) > >>> a > array([[1, 3, 2, 2, 3, 3], > [4, 5, 4, 6, 4, 3]]) > > > > -Travis > > > |
From: Robert K. <rob...@gm...> - 2006-06-02 00:16:59
|
Christopher Barker wrote: > Robert Kern wrote: > >>points = mgrid[minx:maxx, miny:maxy].reshape(2, -1).transpose() > > As I need Numeric and numarray compatibility at this point, it seems the > best I could come up with is below. Ah. It might help if you said that up front. (Untested, but what I usually did in the bad old days before I used scipy): x = arange(minx, maxx+step, step) # oy. y = arange(miny, maxy+step, step) nx = len(x) ny = len(y) x = repeat(x, ny) y = concatenate([y] * nx) points = transpose([x, y]) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Charlie M. <cw...@gm...> - 2006-06-01 23:51:53
|
That reshape should be "resize". Sorry. > Here's my crack at it. > > pts = mgrid[minx:maxx,miny:maxy].transpose() > pts.reshape(pts.size/2, 2) > #pts is good to go > > On 6/1/06, Christopher Barker <Chr...@no...> wrote: > > > > I'm trying to get the (x,y) coords for all the points in a grid, bound > > by xmin, xmax, ymin, ymax. > > > > This list comprehension does it fine: > > > > Points = [(x,y) for x in xrange(minx, maxx) for y in xrange(miny, maxy)] > > > > But I can't think at the moment how to do it with numpy. Any ideas? > > > > Thanks, > > > > -Chris > > > > > > -- > > Christopher Barker, Ph.D. > > Oceanographer > > > > NOAA/OR&R/HAZMAT (206) 526-6959 voice > > 7600 Sand Point Way NE (206) 526-6329 fax > > Seattle, WA 98115 (206) 526-6317 main reception > > > > Chr...@no... > > > > > > ------------------------------------------------------- > > All the advantages of Linux Managed Hosting--Without the Cost and Risk! > > Fully trained technicians. The highest number of Red Hat certifications in > > the hosting industry. Fanatical Support. Click to learn more > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 > > _______________________________________________ > > Numpy-discussion mailing list > > Num...@li... > > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > > > |
From: Christopher B. <Chr...@no...> - 2006-06-01 23:51:49
|
Robert Kern wrote: > points = mgrid[minx:maxx, miny:maxy].reshape(2, -1).transpose() As I need Numeric and numarray compatibility at this point, it seems the best I could come up with is below. I'm guessing the list comprehension may well be faster! -Chris #!/usr/bin/env python #import numpy as N #import Numeric as N import numarray as N Spacing = 2.0 minx = 0 maxx = 5 miny = 20 maxy = 22 print "minx", minx print "miny", miny print "maxx", maxx print "maxy", maxy ## # The nifty, terse, numpy way ## points = mgrid[minx:maxx, miny:maxy].reshape(2, -1).transpose() ## The Numeric and numarray way: x = N.arange(minx, maxx+Spacing, Spacing) # makeing sure to get the last point y = N.arange(miny, maxy+Spacing, Spacing) # an extra is OK points = N.zeros((len(y), len(x), 2), N.Float) x.shape = (1,-1) y.shape = (-1,1) points[:,:,0] += x points[:,:,1] += y points.shape = (-1,2) print points -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: Tom D. <tom...@al...> - 2006-06-01 23:02:20
|
This function is really useful but it seems to only take tuples not ndarrays. This seems kinda strange. Does one have to convert the ndarray into a tuple to use it? This seems extremely inefficient. Is there an efficient way to argsort a 2d array based upon multiple columns if lexsort is not the correct way to do this? The only way I have found to do this is to construct a list of tuples and sort them using python's list sort. This is inefficient and convoluted so I was hoping lexsort would provide a simple solution. --Tom |
From: Christopher B. <Chr...@no...> - 2006-06-01 22:18:52
|
> Charlie Moad wrote: >> pts = mgrid[minx:maxx,miny:maxy].transpose() >> pts.reshape(pts.size/2, 2) Thanks everyone -- yet another reason to dump support for the older num* packages. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: Travis O. <oli...@ie...> - 2006-06-01 22:18:42
|
I will be available during the SciPy 2006 conference to help port open-source applications to NumPy for no charge. (I'm always available for porting commercial code for a reasonable fee). Others who want to assist will be welcome. Conference attendees will get first priority, but others who want to email their request can do so. Offer will be on a first come, first serve basis but I will reserve the liberty to rearrange the order to serve as many projects as possible. I'll place a note on the Wiki Coding Sprint page to this effect. -Travis O. |