Skip to content

Commit

Permalink
planck_clik: fixes segfault when nan in Cl's. partially implements #231
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusTorrado committed May 13, 2022
1 parent a82d0d5 commit 4e85c4d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cobaya/likelihoods/base_classes/planck_clik.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ def log_likelihood(self, cl, **params_values):
[(cl[spectrum][:1 + lmax] if spectrum not in ["tb", "eb"]
else np.zeros(1 + lmax))
for spectrum, lmax in zip(self.requested_cls, self.l_maxs_cls)])
# check for nan's: mey produce a segfault in clik
# dot product is apparently the fastest way in threading-enabled numpy
if np.isnan(np.dot(self.vector, self.vector)):
return -np.inf
# fill with likelihood parameters
self.vector[-len(self.expected_params):] = (
[params_values[p] for p in self.expected_params])
loglike = self.clik(self.vector)[0]
# "zero" of clik
if np.allclose(loglike, -1e30):
# "zero" of clik, and sometimes nan's returned
if np.allclose(loglike, -1e30) or np.isnan(loglike):
loglike = -np.inf
return loglike

Expand Down

0 comments on commit 4e85c4d

Please sign in to comment.