from-python-to-numpy icon indicating copy to clipboard operation
from-python-to-numpy copied to clipboard

neighbours array in game of life example (Uniform Vectorization)

Open aaarbk opened this issue 4 years ago • 3 comments

In the compute_neighbours() function, I think you meant to do N = [[0,]*(shape[1]) for i in range(shape[0])] instead of N = [[0,]*(shape[0]) for i in range(shape[1])]

aaarbk avatar Dec 31 '20 17:12 aaarbk

Thansk. Did you try with non-equal size arrays to check if it is actually wrong? (I don't remember the exact layout I used)

rougier avatar Jan 04 '21 08:01 rougier

Yes I did.

You defined the shape of Z as

shape = len(Z), len(Z[0])

so you want N to be [[0] * ncols for _ in range(nrows)] where (nrows, ncols) = shape

aaarbk avatar Jan 04 '21 09:01 aaarbk

I see, thanks. Can you make a PR?

rougier avatar Jan 05 '21 08:01 rougier