title: Numpy roll in several dimensions
body: <p>I need to shift a 3D array by a 3D vector of displacement for an algorithm.
  As of now I'm using this (admitedly very ugly) method :</p>
  <pre><code>shiftedArray = np.roll(np.roll(np.roll(arrayToShift, shift[0], axis=0)
                                       , shift[1], axis=1),
                               shift[2], axis=2)  
  </code></pre>
  <p>Which works, but means I'm calling 3 rolls ! (58% of my algorithm time is spent in these, according to my profiling)</p>
  <p>From the docs of Numpy.roll:</p>
  <blockquote>
  <p>Parameters:<br />
  shift : int</p>
  <p>axis : int, optional</p>
  </blockquote>
  <p>No mention of array-like in parameter ... So I can't have a multidimensional rolling ?</p>
  <p>I thought I could just call a this kind of function (sounds like a Numpy thing to do) :</p>
  <pre><code>np.roll(arrayToShift,3DshiftVector,axis=(0,1,2))
  </code></pre>
  <p>Maybe with a flattened version of my array reshaped ? but then how do I compute the shift vector ? and is this shift really the same ?</p>
  <p>I'm surprised to find no easy solution for this, as I thought this would be a pretty common thing to do (okay, not <em>that</em> common, but ...)</p>
  <p>So how do we --relatively-- efficiently shift a ndarray by a N-Dimensional vector ?</p>
  <hr />
  <p><strong>Note</strong>: This question was asked in 2015, back when numpy's roll method <strong>did not support this feature</strong>.</p>