The current master version of gradient doesn't check for dimensions less than the stencil size so the line,
   
    out[slice1] = (f[slice2] - f[slice3])

raises an IndexError if you run the code `np.gradient(np.array([[0,1,2,3,4]]))`

What I tried to do here was to just make the error message slightly friendlier i.e. catch the error before the IndexError is automatically returned. As the error is a basic sanity check of the input I thought that a ValueError would be more appropriate. But it would be trivial to change to IndexError("Shape of array...") if that seems better.

As for changing the behavior to allow the silent return of zeros. I would prefer to throw an error. In fact I think an error would be more helpful than returning zeros. Supplying an array of the wrong shape to this function will almost certainly be a programming error and not the intention of the programmer.

Anymore comments or changes?