Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
contradict committed Nov 12, 2023
1 parent 560dbc0 commit be22156
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ end
abstract type SymScope end

struct LocalScope <: SymScope end
function LocalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where N
function LocalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where {N}

Check warning on line 397 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L397

Added line #L397 was not covered by tests
apply_to_variables(sym) do sym
setmetadata(sym, SymScope, LocalScope())
end
Expand All @@ -403,7 +403,7 @@ end
struct ParentScope <: SymScope
parent::SymScope
end
function ParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where N
function ParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where {N}

Check warning on line 406 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L406

Added line #L406 was not covered by tests
apply_to_variables(sym) do sym
setmetadata(sym, SymScope,
ParentScope(getmetadata(value(sym), SymScope, LocalScope())))
Expand All @@ -414,16 +414,18 @@ struct DelayParentScope <: SymScope
parent::SymScope
N::Int
end
function DelayParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, M}}, N) where M
function DelayParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, M}}, N) where {M}

Check warning on line 417 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L417

Added line #L417 was not covered by tests
apply_to_variables(sym) do sym
setmetadata(sym, SymScope,
DelayParentScope(getmetadata(value(sym), SymScope, LocalScope()), N))
end
end
DelayParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where N = DelayParentScope(sym, 1)
function DelayParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where {N}
DelayParentScope(sym, 1)

Check warning on line 424 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L423-L424

Added lines #L423 - L424 were not covered by tests
end

struct GlobalScope <: SymScope end
function GlobalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where N
function GlobalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num, N}}) where {N}

Check warning on line 428 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L428

Added line #L428 was not covered by tests
apply_to_variables(sym) do sym
setmetadata(sym, SymScope, GlobalScope())
end
Expand Down
4 changes: 2 additions & 2 deletions test/variable_scope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ ps = ModelingToolkit.getname.(parameters(level3))

@parameters xx[1:2]
arr_p = [ParentScope(xx[1]), xx[2]]
arr0 = ODESystem(Equation[], t, [], arr_p; name=:arr0)
arr1 = ODESystem(Equation[], t, [], []; name=:arr1) arr0
arr0 = ODESystem(Equation[], t, [], arr_p; name = :arr0)
arr1 = ODESystem(Equation[], t, [], []; name = :arr1) arr0
arr_ps = ModelingToolkit.getname.(parameters(arr1))
@test isequal(arr_ps[1], Symbol("xx"))
@test isequal(arr_ps[2], Symbol("arr0₊xx"))

0 comments on commit be22156

Please sign in to comment.