-
-
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
Do not attempt to promote to Union #3381
base: master
Are you sure you want to change the base?
Conversation
Sometimes `symtype` returns a union like `Union{Float64, Int64}` ```julia julia> @variables x::Float64 1-element Vector{Num}: x julia> ModelingToolkit.symtype(ifelse(x > 0, x, 0)) Union{Float64, Int64} ``` and then ```julia buf = get!(() -> Any[], cachevars, T) ``` fails. This is (very) likely to occur with JSML, which appears to type things with `Float64`
It shouldn't since that's just wrong. |
Yeah |
Also, isn't |
We should enforce the type checks soon. If we do that, then code like this will just error during autodiff, as the user should expect because the assertion would fail. |
It is type unstable, but a component definition like this @component function Ramp(; name, start_time=0, offset=0, duration=nothing, height=nothing)
params = @parameters begin
(start_time::Float64 = start_time)
(offset::Float64 = offset)
(duration::Float64 = duration)
(height::Float64 = height)
end
vars = @variables begin
y(t), [output = true]
end
eqs = Equation[
y ~ ifelse(start_time < t, ifelse(t < start_time + duration, offset + (t - start_time) * height / duration, offset + height), offset)
]
return ODESystem(eqs, t, vars, params; systems = [], name)
end appears to result in this error where the default values for the parameters, |
If a constant appears inside the expression instead of the symbolic expression, that's a much bigger problem with a different solution 😅 since that means the model is incorrectly parsed and changing |
@AayushSabharwal The WaterTreatmentPlant scirpt I pointed you to should reproduce the error that prompted this PR as well |
Sometimes
symtype
returns a union likeUnion{Float64, Int64}
and then
fails.
This is (very) likely to occur with JSML, which appears to type things with
Float64
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.