had forgotten to make replacement of inf with nan inplace, fixed