Skip to content

Commit

Permalink
Add check for invalid values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Segev BenZvi committed Aug 14, 2024
1 parent db684ab commit 9148335
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/snewpy/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9148335

Please sign in to comment.