Re: [Numpy-discussion] computing average distance

2008-11-03 Thread Charles R Harris
On Sun, Nov 2, 2008 at 12:23 PM, Paul Rudin <[EMAIL PROTECTED]> wrote: > > I'm experimenting with numpy and I've just written the code below, which > computes the thing I want (I think). Self.bits is an RxRxR array > representing a voxelized 3d model - values are either 0 or 1. I can't > help thin

Re: [Numpy-discussion] computing average distance

2008-11-02 Thread Paul Rudin
Gael Varoquaux <[EMAIL PROTECTED]> writes: > Hey Emmanuelle, ( :>) > > On Sun, Nov 02, 2008 at 08:39:39PM +0100, Emmanuelle Gouillart wrote: Thanks both of you. >this will avoid what seems to be an error in Emmanuelle's answer. By >the way, I am not too sure why Paul has used a numpy.ar

Re: [Numpy-discussion] computing average distance

2008-11-02 Thread Gael Varoquaux
Hey Emmanuelle, ( :>) On Sun, Nov 02, 2008 at 08:39:39PM +0100, Emmanuelle Gouillart wrote: > although I'm not an expert either, it seems to me you could improve your > code a lot by using numpy.mgrid > Below is a short example of what you could do > coordinates = numpy.mgrid[0:R, 0:R, 0:R] > X,

Re: [Numpy-discussion] computing average distance

2008-11-02 Thread Emmanuelle Gouillart
Hello Paul, although I'm not an expert either, it seems to me you could improve your code a lot by using numpy.mgrid Below is a short example of what you could do coordinates = numpy.mgrid[0:R, 0:R, 0:R] X, Y, Z = coordinates[0].ravel(), coordinates[1].ravel(),coordinates[2].ravel() bits = self.

[Numpy-discussion] computing average distance

2008-11-02 Thread Paul Rudin
I'm experimenting with numpy and I've just written the code below, which computes the thing I want (I think). Self.bits is an RxRxR array representing a voxelized 3d model - values are either 0 or 1. I can't help thinking that's there must be a much nicer way to do it. Any suggestions? centre =