Is there an elegant way to perform a per-line roll of a numpy array? Example:
>>> arr
array([[1, 2, 3, 4],
[5, 6, 7, 8]])
>>> desired_func(arr, shift=np.array([1, 2]))
array([[4, 1, 2, 3],
[7, 8, 5, 6]])
The function np.roll
doesn't seem to allow that.