I have a Python numpy array that I am using for a simulation with toroidal boundary conditions.
For example, at the boundary when i = N-1
, i+1
becomes 0.
I am using a[(i+1)%N, (j+1)%N]
for accessing nearest neighbors so the index automatically wraps around.
Just wondering if there's a faster way to do this, using the Python/Numpy slicing syntax.