ENH: optimize: handle NaNs in curve_fit

curve_fit now raises ValueError if input data contains NaNs.
Previously curve_fit would return nonsensical results.