Q:

python numpy list manipulation

I have the following numpy array:
import numpy as np
a = np.array([2,15,66,180])

Now, I would like that the difference between consecutive elements (diff), divided by 25, is always below or equal to one (diff/25 < 0). 
out = some_function(a,25)
out

[2,15,40,65,66,91,116,141,166,180]
Is there any intelligent pythonic way to do it ?

A:

Numpy arange function might be of use there, I would do it following way:
import numpy as np

a = np.array([2,15,66,180])
out = np.array([])
for i in range(len(a)-1):
    out = np.hstack((out,np.arange(a[i],a[i+1],25)))
out = np.hstack((out,a[-1:]))
print(out)

output:
[   2.   15.   40.   65.   66.   91.  116.  141.  166.  180.]

This solution assumes a is flat array.
EDIT: After while I noticed my solution produces np.array of dtype float64, i.e. different that input - depending on your usage it might or not be a issue. For cases when it is problem I reworked my code to following form:
import numpy as np
a = np.array([2,15,66,180])
print(a.dtype) #int64
out = np.hstack([np.arange(a[i],a[i+1],25) for i in range(len(a)-1)]+[a[-1:]])
print(out) #[  2  15  40  65  66  91 116 141 166 180]
print(out.dtype) #int64

Code is also shorter, but I left original as it might be easier to understand.

