[Numpy-discussion] How do I use numpy to do this?

Robert Kern robert.kern at gmail.com
Thu Jun 1 19:16:40 CDT 2006

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

More information about the Numpy-discussion mailing list