Skip to content

Commit 5581a6e

Browse files
committed
pdf nan outside domain
1 parent 330f902 commit 5581a6e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

petab/v1/distributions.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,15 @@ def _pdf_transformed_untruncated(self, x) -> np.ndarray | float:
177177
)
178178

179179
return np.where(
180-
x > 0,
181-
self._pdf_untransformed_untruncated(self._log(x))
182-
* chain_rule_factor,
183-
0,
180+
x >= 0,
181+
np.where(
182+
x > 0,
183+
self._pdf_untransformed_untruncated(self._log(x))
184+
* chain_rule_factor,
185+
0,
186+
),
187+
# NaN outside its domain
188+
np.nan,
184189
)
185190

186191
@property

tests/v1/test_priors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def cdf(x):
272272
# check that the integral of the PDF is 1 for the unscaled parameters
273273
integral, abserr = quad(
274274
lambda x: prior.pdf(x, x_scaled=False),
275-
-np.inf,
275+
-np.inf if prior.distribution.logbase is False else 0,
276276
np.inf,
277277
limit=100,
278278
epsabs=1e-10,

0 commit comments

Comments
 (0)