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'm wondering if a `check_finite` argument a la linalg would be best here.