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
Describe the bug 🐞
The internal assertions of a function will run into TypeError for the unexpected variable upon using @register_symbolic
Expected behavior
I expected the function to get registered symbolically.
Minimal Reproducible Example 👇
The following block of code will not compile
using ModelingToolkit, DifferentialEquations
import ModelingToolkit: t_nounits as t, D
functionmyfun(x,α,string)
@assert α<1return α
end@register_symbolicmyfun(x,α,string)
@componentfunctionMyComponet(;name,string ="test")
para =@parametersbegin
α
end
vars =@variablesbeginx(t)
end
eqs = [
D(x) ~-exp(-myfun(x,α,string))
]
System(eqs, t, vars, para;name=name)
end@named model =MyComponet()
The code will only work when we register as follows
where as string has nothing to do with the assert statement and is not also called inside the function.
Error & Stacktrace ⚠️
ERROR: LoadError: 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?
Environment (please complete the following information):
string = "test" is a string. If you register it as symbolic it will fail because it's not a symbolic. I'm not sure why that would be a bug? Seems like the type check is working.
Hello,
I think it is a bug because the error message stacktrace points to the @assert statement. Shouldn't the error message be different? Or is my interpretation wrong?
The assert statement has nothing to do with the string.
Describe the bug 🐞
The internal assertions of a function will run into
TypeError
for the unexpected variable upon using@register_symbolic
Expected behavior
I expected the function to get registered symbolically.
Minimal Reproducible Example 👇
The following block of code will not compile
The code will only work when we register as follows
where as
string
has nothing to do with the assert statement and is not also called inside the function.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: