title: numpy.gradient returning nan values when using varargs array with constant values
body: <p>I have an array of timesteps (in seconds) and an array of locations (in latitude). Both arrays are the same size with N=36. I am computing the np.gradient between the two arrays which returns nan values when any two sequential timesteps are the same value. But when I compute the gradient using a constant scalar as the vararg value, I get the correct data output. I need to find a way to create the correct gradient output with varying timesteps. </p>
  
  <p>Using Python 3.4 and Numpy 1.14</p>
  
  <p>I tried computing the gradient with my original timestep array, which returned nan values when the values are the same. Next, I tried computing the gradient with a single scalar value as the vararg input, which gave me the correct output. Then, I tried setting vararg as a numpy array with all the same timestep values, which returned all -inf values. </p>
  
  <pre><code>#Original Code:    
  dt = np.array([10800,10800,9900,5400,6300]) #delta time in seconds
  x = np.array([-85.18,-85.80,-86.3,-87,-87.0]) #delta x in decimal degrees
  dx_dt = np.gradient(x,dt) 
  #returns:
  #[nan,nan, 4.8e-004,-3.1e-004,-2.19e-004]
  
  #Test 1 - test with constant scalar
  dx_dt = np.gradient(x,10800) 
  #returns:
  #[-5.5e-5,-5.1e-5,-5.5e-5,-4.1e-5,-5.1e-5]
  
  #Test 2 - test with constant array
  dt = np.array([10800,10800,10800,10800,10800)]
  dx_dt = np.gradient(x,dt) 
  #returns:
  #[-inf,-inf,-inf,-inf,-inf]
  </code></pre>
  
  <p>I would expect the output of the np.gradient(x,10800) to be the same as the np.gradient(x,np.array([10800,10800,10800,10800,10800])), but it is not. </p>
  
  <p>I need an output without nan or inf values for the next part of the code to work, simply setting the -inf or nans to 0 is not helpful.</p>