title: Zero padding slice past end of array in numpy
body: <p>In numpy, is there a way to zero pad entries if I'm slicing past the end of the array, such that I get something that is the size of the desired slice?</p>
  
  <p>For example, </p>
  
  <pre><code>&gt;&gt;&gt; x = np.ones((3,3,))
  &gt;&gt;&gt; x
  array([[ 1.,  1.,  1.],
         [ 1.,  1.,  1.],
         [ 1.,  1.,  1.]])
  &gt;&gt;&gt; x[1:4, 1:4] # would behave as x[1:3, 1:3] by default
  array([[ 1.,  1.,  0.],
         [ 1.,  1.,  0.],
         [ 0.,  0.,  0.]])
  &gt;&gt;&gt; x[-1:2, -1:2]
   array([[ 0.,  0.,  0.],
         [ 0.,  1.,  1.],
         [ 0.,  1.,  1.]])
  </code></pre>
  
  <p>Visually, I'd like the out-of-bounds areas to be zero padded:</p>
  
  <p><a href="https://i.stack.imgur.com/EPPJ8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EPPJ8.png" alt="enter image description here"></a></p>
  
  <p>I'm dealing with images and would like to zero pad to signify moving off the image for my application. </p>
  
  <p>My current plan is to use np.pad to make the entire array larger prior to slicing, but indexing seems to be a bit tricky. Is there a potentially easier way?</p>