I have an array a = np.arange(10). I want to use np.roll, where the shift can be positive or negative. I then want to use indexing to remove the elements which have been padded to the beginning (if the shift is positive) or end (if the shift is negative) of the array. So for example:
>>> a = np.arange(10)
>>> np.roll(a, 1)[1:]
array([0, 1, 2, 3, 4, 5, 6, 7, 8])
>>> np.roll(a, -1)[:-1]
array([1, 2, 3, 4, 5, 6, 7, 8, 9])
Is there a generic way to accomplish this in a single line?
padding?