Skip to content

Commit 524c100

Browse files
Replaced Python If condition by Pytensor switch
1 parent acb30b1 commit 524c100

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pymc/distributions/continuous.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,12 +1642,14 @@ def logp(value, b, kappa, mu):
16421642
msg="b > 0, kappa > 0",
16431643
)
16441644
def icdf(value, b, kappa, mu):
1645-
if pt.le(b, 0):
1646-
raise ValueError("Scale Parameter b must be positive")
1647-
if pt.le(value, 0.5):
1648-
res = mu - (b / kappa) * pt.log(2 * value)
1649-
if pt.gt(value, 0.5):
1650-
res = mu + (b / kappa) * pt.log(2 * (1 - value))
1645+
res = pt.switch(pt.le(b, 0),
1646+
lambda: raise ValueError("Scale Parameter b must be positive"),
1647+
pt.switch(
1648+
pt.le(value, 0.5),
1649+
lambda: mu - (b / kappa) * pt.log(2 * value),
1650+
lambda: mu + (b / kappa) * pt.log(2 * (1 - value))
1651+
)
1652+
)
16511653
res = check_icdf_parameters(res, value)
16521654
return check_icdf_parameters(
16531655
res,

0 commit comments

Comments
 (0)