I noticed something weird today. The exact same inputs and code were exhibiting completely different behaviour on two different clusters.
The only difference between them was SciPy versions:
0.10.1 (correct behaviour) and
0.12.0 (incorrect behaviour). Here’s the line
The correct behaviour on
The incorrect behaviour on
0.12.0 (after excluding all other differences and possibilities):
You can see that
errfunc behaves the same way, but
scipy.optimize.leastsq does not. Well, if you ever have this problem too then all you
need to do is edit the
epsfcn flag. The
epsfcn flag is described as:
A suitable step length for the forward-difference approximation of the Jacobian (for Dfun=None). If epsfcn is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.
0.10.1 the default value is
0.0, but in
0.12.0 the default value is
None. In this example,
are very different beasts, which makes the default behaviour for
scipy.optimize.leastsq unintuitively different between versions.
0.12.0 (the previously ‘incorrect’ behaviour):
So there you go. If you’re using
scipy.optimize.leastsq, make sure you specify
0.0 (or whatever) to be sure your code is future-compatible.