numpy.take
in 'wrap'
mode will use your indices modulo the length of the array.
indices = range(i-2,i+3)
neighbourhood = A.take(indices, mode="wrap")
See documentation for details numpy.take
numpy.take
in 'wrap'
mode will use your indices modulo the length of the array.
indices = range(i-2,i+3)
neighbourhood = A.take(indices, mode="wrap")
See documentation for details numpy.take