How to return 0 with divide by zero
I’m trying to perform an element wise divide in python, but if a zero is encountered, I need the quotient to just be zero.
I’m trying to perform an element wise divide in python, but if a zero is encountered, I need the quotient to just be zero.
I have to make a Lagrange polynomial in Python for a project I’m doing. I’m doing a barycentric style one to avoid using an explicit for-loop as opposed to a Newton’s divided difference style one. The problem I have is that I need to catch a division by zero, but Python (or maybe numpy) just makes it a warning instead of a normal exception.