Skip to content

Commit 06192df

Browse files
fix: fix namespacing of array variables using unknowns
1 parent 84396da commit 06192df

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/systems/abstractsystem.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,10 @@ function defaults(sys::AbstractSystem)
10211021
end
10221022

10231023
unknowns(sys::Union{AbstractSystem, Nothing}, v) = renamespace(sys, v)
1024+
for vType in [Symbolics.Arr, Symbolics.Symbolic{<:AbstractArray}]
1025+
@eval unknowns(sys::AbstractSystem, v::$vType) = renamespace(sys, v)
1026+
@eval parameters(sys::AbstractSystem, v::$vType) = toparam(unknowns(sys, v))
1027+
end
10241028
parameters(sys::Union{AbstractSystem, Nothing}, v) = toparam(unknowns(sys, v))
10251029
for f in [:unknowns, :parameters]
10261030
@eval function $f(sys::AbstractSystem, vs::AbstractArray)

test/odesystem.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,3 +1159,9 @@ for sys in [sys1, sys2]
11591159
@test variable_index(sys, x[i]) == variable_index(sys, x)[i]
11601160
end
11611161
end
1162+
1163+
# Namespacing of array variables
1164+
@variables x(t)[1:2]
1165+
@named sys = ODESystem(Equation[], t)
1166+
@test getname(unknowns(sys, x)) == :sys₊x
1167+
@test size(unknowns(sys, x)) == size(x)

0 commit comments

Comments
 (0)