You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like it is evaluating both log(x) and log(-x). But the underlying printer doesn't seem to do this:
In [6]: from sympy.printing import lambdarepr
In [9]: lambdarepr.lambdarepr(f)
Out[9]: '((log(-x)) if (x < 0) else (((log(x)) if (True) else None)))'
In [12]: x = 10
In [13]: ((np.log(-x)) if (x < 0) else (((np.log(x)) if (True) else None)))
Out[13]: 2.3025850929940459
It has to use np.select so that the if-then-else gets vectorized, meaning the "incorrect" branch is always evaluated. This was also the problem with #11306. Is there a better NumPy function we can use with lambdify that doesn't evaluate unused branches, but still works on arrays? Such a function would be more efficient too.
Regarding the issue, the warning can be ignored. The invalid value isn't actually used, assuming your piecewise is setup correctly.
Simple example:
gives:
Value is calculated correctly, then why is there a warning?
The text was updated successfully, but these errors were encountered: