I would like to split an array into equally long intersecting subarrays (last element of previous array coincides with first element of the next array and with periodic boundary conditions).
E.g.
myarray = np.arange(18)
output:
splitarray = [[0,1,2,3,4],[4,5,6,7,8],[8,9,10,11,12],[12,13,14,15,16],[16,17,0,1,2]]
(the 3 last elements of the last subarray correspond to the first 3 elements of the initial array!)
What is the most efficient way to implement this in Python?