I noticed this when searching around numpy.gradient()
usages. It seems that since numpy 1.13, the function treats it input argument differently than previous versions. Here is a simple example:
import numpy as np
x=np.linspace(0,10,100)
y=np.sin(x)
dx=np.gradient(x)
grad1=np.gradient(y,dx)
print grad1
grad2=np.gradient(y,x)
print grad2
I tested in numpy 1.13 and 1.11.3.
In 1.13, gradient(array1, array2)
treats array2
as coordinates (x) for array1
. But in 1.11.3, it treats array2
as the differentiation of coordinates (dx). So grad1
works in 1.11.3, and grad2
works for 1.13.
I think this is a rather dangeous trap, people may get wrong results if the same code is run using different versions of numpy. Or am I missing something obvious that clears this ambiguity?