This may be a little redundant, but I always use the np.take function for any indexing of the wrapper:
>>> a = np.array([1, 2, 3]) >>> np.take(a, range(0, len(a)+1), mode='wrap') array([1, 2, 3, 1]) >>> np.take(a, range(-1, len(a)+1), mode='wrap') array([3, 1, 2, 3, 1])
Simon Streicher Jan 25 '16 at 15:29 2016-01-25 15:29
source share