Re: [Numpy-discussion] Multidimensional neighbours

2012-08-17 Thread Jose Gomez-Dans
Hi, On 16 August 2012 19:38, Sebastian Berg wrote: > Hello, > > Just to throw it in, if you do not mind useing scipy, you can use its > multidimensional correlate method instead: > Well, I don't need to count the number of neighbours as in the linked example. What I wanted to have is easy acces

Re: [Numpy-discussion] Multidimensional neighbours

2012-08-16 Thread Cera, Tim
I have a pull request for a neighborhood function at https://github.com/numpy/numpy/pull/303 . I think IMHO it handles these problems quite handily. It does rely on my pad routine that is in Numpy 1.7, so you would need to get the 1.7 beta installed or install the development branch. For your e

Re: [Numpy-discussion] Multidimensional neighbours

2012-08-16 Thread Sebastian Berg
Hello, Just to throw it in, if you do not mind useing scipy, you can use its multidimensional correlate method instead: stamp = np.ones((3,3,3)) stamp[1,1,1] = 0 num_neighbours = scipy.ndimage.correlate(x, stamp, mode='wrap')) In the link np.roll is used to implement periodic boundaries (mode='w

[Numpy-discussion] Multidimensional neighbours

2012-08-16 Thread Jose Gomez-Dans
Hi, I've just come across Travis Oliphant's array version of the game of life here . It's a really nice example of how to efficiently find neighbours using numpy and family. However, I wanted to apply these ideas to higher order arrays (eg GRID being three dimension