We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This difference doesn't make sense. When 1 is a float
>>> x = Symbol('x') >>>Piecewise((123, x < 1), (456, x >= 1.0)) Piecewise((123, x < 1), (456, x >= 1.0))
but if 1 is an int
>>> Piecewise( (123, x<1), (456 , x>=1) ) Piecewise((123, x < 1), (456, True))
I think there is the 'otherwise' behavior here. If I put more (exprs, conds) after the second Piecewise, they don't show up.
>>>Piecewise( (123, x<1), (456 , x>=1) , (789, x>4) ) Piecewise((123, x < 1), (456, True))
It shows up using the float(1).
>>>Piecewise( (123, x<1), (456 , x>=1.) , (789, x>4) ) Piecewise( (123, x<1), (456 , x>=1.) , (789, x>4) )
The text was updated successfully, but these errors were encountered:
..wait was i supposed to nest Piecewise?
Sorry, something went wrong.
Looks like there is deduction going on (assuming x is real I suppose). Is this what you're looking for?:
>>> pw = sympy.Piecewise((123, x<1), (456, x<=4), (789, 4<x)) >>> pw Piecewise((123, x < 1), (456, x <= 4), (789, x > 4))
then using e.g. lambdify you get:
lambdify
>>> l = sympy.lambdify(x, pw) >>> l(0.5) array(123.) >>> l(1.5) array(456.) >>> l(4.5) array(789.)
why do i have to do it like that? i don't see the logical difference.
I wouldn't be surprised if this boils down to #11707.
No branches or pull requests
This difference doesn't make sense.
When 1 is a float
but if 1 is an int
I think there is the 'otherwise' behavior here. If I put more (exprs, conds) after the second Piecewise, they don't show up.
It shows up using the float(1).
The text was updated successfully, but these errors were encountered: