If you set np.seterr(all='ignore') or np.seterr(under='ignore') numpy is smart enough to set the result to zero without raising any error.
np.seterr(all='ignore')
np.seterr(under='ignore')