ENH: optimize: handle NaNs in curve_fit

curve_fit now raises ValueError if input data contains NaNs.
Previously curve_fit would return nonsensical results.
Fixes #3422
I should add that I'm only +0 on the check_finite flag here.