- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
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
Faulty non-boolean error in ifelse() #3441
Comments
You have to use |
Thanks, I will move this issue to another repo, as the code was autogenereated. |
@baggepinnen just to be clear, the key point here is that both work on booleans but only |
|
When I run
The MTK code is now after installing @mtiller-jh 's updates:
|
I think you might need parentheses in |
@SebastianM-C Yes it does. The equation should be then: |
This has bitten me several times as well and is as Sebastian points out due to the different precedence of this operator. I think it has this precedence due to it's use for bit-level manipulation of integers, it's documented as |
@SebastianM-C I've requested your review on this... https://github.com/JuliaComputing/jsml-kernel/pull/232 It should address this issue. |
Describe the bug 🐞
When I attempt to build an MTK model, I get an error:
ERROR: TypeError: non-boolean (Num) used in boolean context
A symbolic expression appeared in a Boolean context. This error arises in situations where Julia expects a Bool, like
if boolean_condition use ifelse(boolean_condition, then branch, else branch)
x && y use x & y
boolean_condition ? a : b use ifelse(boolean_condition, a, b)
but a symbolic expression appeared instead of a Bool. For help regarding control flow with symbolic variables, see https://docs.sciml.ai/ModelingToolkit/dev/basics/FAQ/#How-do-I-handle-if-statements-in-my-symbolic-forms?
Expected behavior
I don't see any non-booleans in the ifelse function, so I would expect it to build.
Minimal Reproducible Example 👇
Without MRE, we would only be able to help you to a limited extent, and attention to the issue would be limited. to know more about MRE refer to wikipedia and stackoverflow.
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: