-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Open
Labels
Description
In the API documentation it says
ITE(A, B, C) evaluates and returns the result of B if A is true else it returns the result of C.
however it likely evaluates B
even if A
is false.
import sympy as sym
beta = sym.Symbol("beta")
expr = sym.ITE(sym.Abs(beta) > 0, 1/beta > 1, False)
expr.subs(beta, 0)
This yields TypeError: Invalid comparison of non-real zoo
. We can manually evaluate each args
but it means we cannot safely lambdify this expression. Seems like these lines are causing the problem.
Lines 1076 to 1082 in 66d7aef
for i, arg in enumerate(args): | |
if not hasattr(arg, '_eval_subs'): | |
continue | |
arg = arg._subs(old, new, **hints) | |
if not _aresame(arg, args[i]): | |
hit = True | |
args[i] = arg |