Convert boolean in float #22289
Answered
by
redeboer
Simone2021space
asked this question in
Q&A
-
Hi team, where z is a symbol, so if z is less than 0.1 the expression is 1, otherwise it is 0. "TypeError: unsupported operand type(s) for *: 'StrictLessThan' and 'float' " |
Beta Was this translation helpful? Give feedback.
Answered by
redeboer
Oct 15, 2021
Replies: 2 comments
-
Sounds like you are looking for >>> import sympy as sp
>>> z = sp.Symbol("z")
>>> expr = sp.Piecewise(
... (z, z < 0.1),
... (1.0, True),
... )
>>> expr.subs(z, .05)
0.05
>>> expr.subs(z, 2)
1.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Simone2021space
-
There is an issue about adding an indicator function #19481 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sounds like you are looking for
Piecewise
: