Replace -inf with zero value

user1821176 picture user1821176 · Jan 10, 2014 · Viewed 77.1k times · Source

I have an array:

x =  numpy.array([-inf, -inf, 37.49668579])

Is there a way to change the -inf values to just 0?

Answer

pv. picture pv. · Jan 10, 2014

There is:

from numpy import inf
x[x == -inf] = 0