Skip to content

Commit 4c8d09c

Browse files
shashiYingboMa
andcommitted
toparam changes
Co-authored-by: "Yingbo Ma" <[email protected]>
1 parent f9c7083 commit 4c8d09c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/parameters.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ isparameter(x) = false
1010
1111
Maps the variable to a paramter.
1212
"""
13-
toparam(s::Symbolic) = setmetadata(s, MTKParameterCtx, true)
13+
function toparam(s)
14+
if s isa Symbolics.Arr
15+
Symbolics.wrap(toparam(Symbolics.unwrap(s)))
16+
elseif s isa AbstractArray
17+
map(toparam, s)
18+
elseif symtype(s) <: AbstractArray
19+
Symbolics.recurse_and_apply(toparam, s)
20+
else
21+
setmetadata(s, MTKParameterCtx, true)
22+
end
23+
end
1424
toparam(s::Num) = Num(toparam(value(s)))
1525

1626
"""
@@ -40,7 +50,6 @@ macro parameters(xs...)
4050
Symbolics._parse_vars(:parameters,
4151
Real,
4252
xs,
43-
x -> x isa AbstractArray ?
44-
Symbolics.recurse_and_apply(toparam, x) : toparam(x),
53+
toparam,
4554
) |> esc
4655
end

0 commit comments

Comments
 (0)