scipy.optimize.leastsq: allow ValueError as well as LinAlgError when inverting curvature matrix