I have a big data set of floating point numbers. I iterate through them and evaluate np.log(x) for each of them. I get
np.log(x)
RuntimeWarning: divide b
You can do this.
def safe_ln(x): try: l = np.log(x) except ZeroDivisionError: l = 0 return l