ENH: optimize: handle NaNs in curve_fit

curve_fit now raises ValueError if input data contains NaNs.
Previously curve_fit would return nonsensical results.
ENH: optimize: add check_finite flag to curve_fit
Merge pull request #4187 from ev-br/pr/3923_

ENH: optimize: handle NaNs in curve_fit