[Python] RuntimeWarning: divide by zero encountered in log

Discussão em 'Python' iniciado por Stack, Março 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am using numpy.log10 to calculate the log of an array of probability values. There are some zeros in the array, and I am trying to get around it using

    result = numpy.where(prob > 0.0000000001, numpy.log10(prob), -10)


    However, RuntimeWarning: divide by zero encountered in log10 still appeared and I am sure it is this line caused the warning.

    Although my problem is solved, I am confused why this warning appeared again and again?

    Continue reading...

Compartilhe esta Página