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 am not sure that it is worth it to complicate the API. If the user supplies a function which can handle infs, then she is probably skilled enough to work around the limited API of `curve_fit` by taking care of removing the infs from `xdata`. But removing the check has a cost for all users, because currently we are returning nonsensical results if `xdata` has infs. I don't see a way of making both user classes equally happy in this case.