From 9148335e648fd374d799431c0cfd0d646adbfaa2 Mon Sep 17 00:00:00 2001 From: Segev BenZvi Date: Wed, 14 Aug 2024 10:18:51 -0500 Subject: [PATCH] Add check for invalid values. --- python/snewpy/models/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/snewpy/models/base.py b/python/snewpy/models/base.py index 4a147802..49e13a7a 100644 --- a/python/snewpy/models/base.py +++ b/python/snewpy/models/base.py @@ -299,8 +299,8 @@ def get_initial_spectra(self, t, E, flavors=Flavor): a = np.expand_dims(a, axis=1) # For numerical stability, evaluate log PDF and then exponentiate. - # Suppress div-by-zero warnings and remove bad values later. - with np.errstate(divide='ignore'): + # Suppress div-by-zero and other warnings that do not matter here. + with np.errstate(divide='ignore', invalid='ignore'): result = \ np.exp(np.log(L) - (2+a)*np.log(Ea) + (1+a)*np.log(1+a) - loggamma(1+a) + a*np.log(E) - (1+a)*(E/Ea)) / (u.erg * u.s)