-
-
Notifications
You must be signed in to change notification settings - Fork 236
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug 🐞
I'm really sorry for spamming your issue tracker, but I'll provide MWEs at least...
A simplified system has weird behaviour for hasproperty and getproperty: namely it might lie about properties being present or not present!
Expected behavior
hasproperty true => getproperty does not error
hasproperty false => getproperty errors
Minimal Reproducible Example 👇
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as Dt
@mtkmodel Inner begin
@parameters begin
p
end
end
@mtkmodel Outer begin
@components begin
inner = Inner()
end
@variables begin
x(t)
end
@equations begin
x ~ inner.p
end
end
@named outer = Outer()
simp = structural_simplify(outer)
hasproperty(outer, :inner) # true
outer.inner # works
hasproperty(outer, :inner₊p) # false
outer.inner₊p # errors as expected
hasproperty(simp, :inner) # false
simp.inner # still works
hasproperty(simp, :inner₊p) # true
inner.inner₊p # errors despite hasproperty trueError & Stacktrace
julia> outer.inner₊p # errors despite hasproperty
ERROR: ArgumentError: System outer: variable inner₊p does not exist
Stacktrace:
[1] getvar(sys::ODESystem, name::Symbol; namespace::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/abstractsystem.jl:1066
[2] getproperty(sys::ODESystem, name::Symbol; namespace::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/abstractsystem.jl:1009
[3] getproperty(sys::ODESystem, name::Symbol)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/yfT8s/src/systems/abstractsystem.jl:1005
[4] top-level scope
@ none:1Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
Status `/tmp/jl_QTt44V/Project.toml`
[961ee093] ModelingToolkit v9.36.0- Output of
versioninfo()
julia> versioninfo()
Julia Version 1.11.0-rc3
Commit 616e45539db (2024-08-26 15:46 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 × AMD Ryzen 9 8945HS w/ Radeon 780M Graphics
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 16 default, 0 interactive, 8 GC (on 16 virtual cores)
Environment:
JULIA_NUM_THREADS = autoMetadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working