title: numpy - how to slice of an array passed the limit of the array and back to the beginning
body: <p><a href="https://i.stack.imgur.com/mZbNH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZbNH.jpg" alt="enter image description here" /></a></p>
  <p>I have an image in a numpy array and I want to take the slice in red.</p>
  <p>I expect the output to look like this.</p>
  <p><a href="https://i.stack.imgur.com/YaI9g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YaI9g.png" alt="enter image description here" /></a></p>
  <p>Imagine the shape is [600,800,3]</p>
  <p>I've tried <code>img[200:400,400:900,:]</code> the 900 being higher than the limit hoping it would wrap around but no.</p>
  <p>I know i could also take it as two slices and then hstack them, but i cant help think there is a better way?</p>
  <p>Its also possible that the slice could overrun horizontally or vertically or both.</p>
  <p>Any suggestions?</p>