Logo

Programming-Idioms

  • PHP
  • Python

Idiom #194 Circular shift of a two-dimensional array

Given an array a, set b to an array which has the values of a along its second dimension shifted by n. Elements shifted out should come back at the other end.

import numpy as np
b = np.roll(a, m, axis=1)
b = cshift(a,n,dim=2)

New implementation...
< >
tkoenig