“Divide by zero encountered in log” when not dividing by zero

That’s the warning you get when you try to evaluate log with 0:

>>> import numpy as np
>>> np.log(0)
__main__:1: RuntimeWarning: divide by zero encountered in log

I agree it’s not very clear.

So in your case, I would check why your input to log is 0.

PS: this is on numpy 1.10.4

Leave a Comment