Numba njit “ZeroDivisionError: division by zero”

In a normal njit function setting error_model=”numpy” does exactly this. There are also significant speedups possible by setting this option. So:

@njit(error_model="numpy")

If you are wandering what Numba is, read more about Numba here. It's a really cool thing, I highly recommend getting familiar with it.