Skip to content

Commit eda30b9

Browse files
fix: complete with split = false removes the index cache
1 parent 76805be commit eda30b9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/systems/abstractsystem.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,8 @@ function complete(sys::AbstractSystem; split = true, flatten = true)
985985
end
986986
@set! sys.ps = ordered_ps
987987
end
988+
elseif has_index_cache(sys)
989+
@set! sys.index_cache = nothing
988990
end
989991
if isdefined(sys, :initializesystem) && get_initializesystem(sys) !== nothing
990992
@set! sys.initializesystem = complete(get_initializesystem(sys); split)

test/odesystem.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,3 +1495,12 @@ end
14951495
sys2 = complete(sys)
14961496
@test length(equations(sys2)) == total_eqs
14971497
end
1498+
1499+
@testset "`complete` with `split = false` removes the index cache" begin
1500+
@variables x(t)
1501+
@parameters p
1502+
@mtkbuild sys = ODESystem(D(x) ~ p * t, t)
1503+
@test ModelingToolkit.get_index_cache(sys) !== nothing
1504+
sys2 = complete(sys; split = false)
1505+
@test ModelingToolkit.get_index_cache(sys2) === nothing
1506+
end

0 commit comments

Comments
 (0)