Skip to content

Commit 0e04e8a

Browse files
authored
Merge pull request #2428 from SciML/myb/var
Consistent variable creation
2 parents eb33a8a + 90124ec commit 0e04e8a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/systems/model_parsing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function generate_var!(dict, a, b, varclass;
219219
vd isa Vector && (vd = first(vd))
220220
vd[a] = Dict{Symbol, Any}()
221221
var = if indices === nothing
222-
Symbolics.variable(a, T = SymbolicUtils.FnType{Tuple{Real}, Real})(iv)
222+
Symbolics.variable(a, T = SymbolicUtils.FnType{Tuple{Any}, Real})(iv)
223223
else
224224
vd[a][:size] = Tuple(lastindex.(indices))
225225
first(@variables $a(iv)[indices...])

test/model_parsing.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,9 @@ end
329329
# Ensure that modules consisting MTKModels with component arrays and icons of
330330
# `Expr` type and `unit` metadata can be precompiled.
331331
module PrecompilationTest
332-
using Unitful, Test, ModelingToolkit
332+
push!(LOAD_PATH, joinpath(@__DIR__, "precompile_test"))
333+
using Unitful, Test, ModelParsingPrecompile, ModelingToolkit
333334
@testset "Precompile packages with MTKModels" begin
334-
push!(LOAD_PATH, joinpath(@__DIR__, "precompile_test"))
335-
336335
using ModelParsingPrecompile: ModelWithComponentArray
337336

338337
@named model_with_component_array = ModelWithComponentArray()
@@ -539,3 +538,16 @@ end
539538
@test Equation[ternary_true.ternary_parameter_true ~ 0] == equations(ternary_true)
540539
@test Equation[ternary_false.ternary_parameter_false ~ 0] == equations(ternary_false)
541540
end
541+
542+
_b = Ref{Any}()
543+
@mtkmodel MyModel begin
544+
@variables begin
545+
x___(t) = 0
546+
end
547+
begin
548+
_b[] = x___
549+
end
550+
end
551+
@named m = MyModel()
552+
@variables t x___(t)
553+
@test isequal(x___, _b[])

0 commit comments

Comments
 (0)