[Numpy-discussion] new warning in 1.5.0: divide by zero encountered in log
Wed Sep 8 05:38:24 CDT 2010
I recently upgraded to numpy 1.5.0 and now I get warnings when I take
the logarithm of 0.
In : np.log(0.)
Warning: divide by zero encountered in log
I want to evaluate x * log(x) where its value is defined as 0 when x=0
so I have the following function:
"@return: x log(x) but replaces -inf with 0."
l = np.log(x)
result = x * l
result[np.isneginf(l)] = 0.
Is there a better way of doing this that won't give me all these
warnings? Can I turn the warnings off?
More information about the NumPy-Discussion