I think that you could use a 'with np.errstate:' here.