Skip to content

Commit

Permalink
switch np.isinf to np.isfinite
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMatt committed May 1, 2024
1 parent d5ee16a commit 8890643
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions harmonic/evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def compute_evidence(self):
evidence_inv = np.exp(self.ln_evidence_inv)
evidence_inv_var = np.exp(self.ln_evidence_inv_var)

if np.isinf(np.nan_to_num(evidence_inv, nan=np.inf)) or np.isinf(np.nan_to_num(evidence_inv_var, nan=np.inf)):
if not np.isfinite(evidence_inv) or not np.isfinite(evidence_inv_var):
raise ValueError("Evidence is too large to represent in non-log space. Use log-space values instead.")

common_factor = 1.0 + evidence_inv_var / (evidence_inv**2)
Expand Down Expand Up @@ -574,9 +574,9 @@ def compute_bayes_factor(ev1, ev2):
evidence_inv_ev2 = np.exp(ev2.ln_evidence_inv)
evidence_inv_var_ev2 = np.exp(ev2.ln_evidence_inv_var)

if np.isinf(np.nan_to_num(evidence_inv_ev1, nan=np.inf)) or np.isinf(np.nan_to_num(evidence_inv_var_ev1, nan=np.inf)):
if not np.isfinite(evidence_inv_ev1) or not np.isfinite(evidence_inv_var_ev1):
raise ValueError("Evidence for model 1 is too large to represent in non-log space. Use log-space values instead.")
if np.isinf(np.nan_to_num(evidence_inv_ev2, nan=np.inf)) or np.isinf(np.nan_to_num(evidence_inv_var_ev2, nan=np.inf)):
if not np.isfinite(evidence_inv_ev2) or not np.isfinite(evidence_inv_var_ev2):
raise ValueError("Evidence for model 2 is too large to represent in non-log space. Use log-space values instead.")

common_factor = 1.0 + evidence_inv_var_ev1 / (evidence_inv_ev1**2)
Expand Down

0 comments on commit 8890643

Please sign in to comment.