Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: complete with split = false removes the index cache #3184

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ function complete(sys::AbstractSystem; split = true, flatten = true)
end
@set! sys.ps = ordered_ps
end
elseif has_index_cache(sys)
@set! sys.index_cache = nothing
end
if isdefined(sys, :initializesystem) && get_initializesystem(sys) !== nothing
@set! sys.initializesystem = complete(get_initializesystem(sys); split)
Expand Down Expand Up @@ -3001,8 +3003,8 @@ By default, the resulting system inherits `sys`'s name and description.
See also [`compose`](@ref).
"""
function extend(sys::AbstractSystem, basesys::AbstractSystem;
name::Symbol = nameof(sys), description = description(sys),
gui_metadata = get_gui_metadata(sys))
name::Symbol = nameof(sys), description = description(sys),
gui_metadata = get_gui_metadata(sys))
T = SciMLBase.parameterless_type(basesys)
ivs = independent_variables(basesys)
if !(sys isa T)
Expand Down
9 changes: 9 additions & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1495,3 +1495,12 @@ end
sys2 = complete(sys)
@test length(equations(sys2)) == total_eqs
end

@testset "`complete` with `split = false` removes the index cache" begin
@variables x(t)
@parameters p
@mtkbuild sys = ODESystem(D(x) ~ p * t, t)
@test ModelingToolkit.get_index_cache(sys) !== nothing
sys2 = complete(sys; split = false)
@test ModelingToolkit.get_index_cache(sys2) === nothing
end
Loading