simply use `isfinite`
Merge pull request #2182 from cremno/use-isfinite

simply use `isfinite`