Skip to content

fix: fix simplification of empty systems #3890

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

Merged
merged 1 commit into from
Aug 12, 2025
Merged
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
2 changes: 1 addition & 1 deletion src/systems/systemstructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ function mtkcompile!(state::TearingState; simplify = false,
time_domains = merge(Dict(state.fullvars .=> ci.var_domain),
Dict(default_toterm.(state.fullvars) .=> ci.var_domain))
tss, clocked_inputs, continuous_id, id_to_clock = ModelingToolkit.split_system(ci)
if continuous_id == 0
if !isempty(tss) && continuous_id == 0
# do a trait check here - handle fully discrete system
additional_passes = get(kwargs, :additional_passes, nothing)
if !isnothing(additional_passes) && any(discrete_compile_pass, additional_passes)
Expand Down
6 changes: 6 additions & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1628,3 +1628,9 @@ import Test: @test
@mtkbuild sys = System(D(x) ~ t, t)
@test sys isa System
end

@testset "Empty system can be simplified" begin
@named sys = System(Equation[], t)
ss = mtkcompile(sys)
@test length(equations(ss)) == length(unknowns(ss)) == 0
end
Loading