From 5f355094bf9e83aeda2a2c9ff5d1d8c890249891 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 27 Jul 2025 12:00:41 -0400 Subject: [PATCH 1/5] Remove outdated Julia version checks from tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Julia v1.10 is now the LTS version, remove conditional code for: - Julia v1.7 check in test/clock.jl - Julia v1.5 check in test/direct.jl - Julia v1.8 check in test/input_output_handling.jl These version checks are no longer necessary as the minimum supported Julia version is now well above these thresholds. đŸ¤– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- test/clock.jl | 68 +++++++++++++++++------------------ test/direct.jl | 30 ++++++++-------- test/input_output_handling.jl | 6 ++-- 3 files changed, 49 insertions(+), 55 deletions(-) diff --git a/test/clock.jl b/test/clock.jl index 7afd7572fb..446b0ffb0d 100644 --- a/test/clock.jl +++ b/test/clock.jl @@ -298,43 +298,41 @@ eqs = [yd ~ Sample(dt)(y) ss = mtkcompile(cl) ss_nosplit = mtkcompile(cl; split = false) - if VERSION >= v"1.7" - prob = ODEProblem(ss, [x => 0.0, kp => 1.0], (0.0, 1.0)) - prob_nosplit = ODEProblem(ss_nosplit, [x => 0.0, kp => 1.0], (0.0, 1.0)) - sol = solve(prob, Tsit5(), kwargshandle = KeywordArgSilent) - sol_nosplit = solve(prob_nosplit, Tsit5(), kwargshandle = KeywordArgSilent) - - function foo!(dx, x, p, t) - kp, ud1, ud2 = p - dx[1] = -x[1] + ud1 + ud2 - end + prob = ODEProblem(ss, [x => 0.0, kp => 1.0], (0.0, 1.0)) + prob_nosplit = ODEProblem(ss_nosplit, [x => 0.0, kp => 1.0], (0.0, 1.0)) + sol = solve(prob, Tsit5(), kwargshandle = KeywordArgSilent) + sol_nosplit = solve(prob_nosplit, Tsit5(), kwargshandle = KeywordArgSilent) - function affect1!(integrator) - kp = integrator.p[1] - y = integrator.u[1] - r = 1.0 - ud1 = kp * (r - y) - integrator.p[2] = ud1 - nothing - end - function affect2!(integrator) - kp = integrator.p[1] - y = integrator.u[1] - r = 1.0 - ud2 = kp * (r - y) - integrator.p[3] = ud2 - nothing - end - cb1 = PeriodicCallback(affect1!, dt; final_affect = true, initial_affect = true) - cb2 = PeriodicCallback(affect2!, dt2; final_affect = true, initial_affect = true) - cb = CallbackSet(cb1, cb2) - # kp ud1 ud2 - prob = ODEProblem(foo!, [0.0], (0.0, 1.0), [1.0, 1.0, 1.0], callback = cb) - sol2 = solve(prob, Tsit5()) - - @test sol.u≈sol2.u atol=1e-6 - @test sol_nosplit.u≈sol2.u atol=1e-6 + function foo!(dx, x, p, t) + kp, ud1, ud2 = p + dx[1] = -x[1] + ud1 + ud2 + end + + function affect1!(integrator) + kp = integrator.p[1] + y = integrator.u[1] + r = 1.0 + ud1 = kp * (r - y) + integrator.p[2] = ud1 + nothing end + function affect2!(integrator) + kp = integrator.p[1] + y = integrator.u[1] + r = 1.0 + ud2 = kp * (r - y) + integrator.p[3] = ud2 + nothing + end + cb1 = PeriodicCallback(affect1!, dt; final_affect = true, initial_affect = true) + cb2 = PeriodicCallback(affect2!, dt2; final_affect = true, initial_affect = true) + cb = CallbackSet(cb1, cb2) + # kp ud1 ud2 + prob = ODEProblem(foo!, [0.0], (0.0, 1.0), [1.0, 1.0, 1.0], callback = cb) + sol2 = solve(prob, Tsit5()) + + @test sol.u≈sol2.u atol=1e-6 + @test sol_nosplit.u≈sol2.u atol=1e-6 ## @info "Testing hybrid system with components" diff --git a/test/direct.jl b/test/direct.jl index ce2a3f5785..5f52a54fea 100644 --- a/test/direct.jl +++ b/test/direct.jl @@ -240,22 +240,20 @@ kwargs = (; name = 3) @test cool_name[1] == (42,) @test collect(cool_name[2]) == [:name => 3] -if VERSION >= v"1.5" - name = 3 - @named cool_name = foo(42; name) - @test cool_name[1] == (42,) - @test collect(cool_name[2]) == [:name => name] - @named cool_name = foo(; name) - @test collect(cool_name) == [:name => name] - - ff = 3 - @named cool_name = foo(42; ff) - @test cool_name[1] == (42,) - @test collect(cool_name[2]) == [pp; :ff => ff] - - @named cool_name = foo(; ff) - @test collect(cool_name) == [pp; :ff => ff] -end +name = 3 +@named cool_name = foo(42; name) +@test cool_name[1] == (42,) +@test collect(cool_name[2]) == [:name => name] +@named cool_name = foo(; name) +@test collect(cool_name) == [:name => name] + +ff = 3 +@named cool_name = foo(42; ff) +@test cool_name[1] == (42,) +@test collect(cool_name[2]) == [pp; :ff => ff] + +@named cool_name = foo(; ff) +@test collect(cool_name) == [pp; :ff => ff] foo(i; name) = (; i, name) @named goo[1:3] = foo(10) diff --git a/test/input_output_handling.jl b/test/input_output_handling.jl index e053584776..54fdbfc1b4 100644 --- a/test/input_output_handling.jl +++ b/test/input_output_handling.jl @@ -8,10 +8,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D eqs = [D(xx) ~ some_input] @named model = System(eqs, t) @test_throws ExtraVariablesSystemException mtkcompile(model) -if VERSION >= v"1.8" - err = "In particular, the unset input(s) are:\n some_input(t)" - @test_throws err mtkcompile(model) -end +err = "In particular, the unset input(s) are:\n some_input(t)" +@test_throws err mtkcompile(model) # Test input handling @variables x(t) u(t) [input = true] v(t)[1:2] [input = true] From 5dd1471b0785f64cfc9c832afdef9325522e0124 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 27 Jul 2025 12:04:23 -0400 Subject: [PATCH 2/5] Remove code inside outdated Julia version checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per review feedback, completely remove the code that was inside version checks rather than just removing the conditionals. This removes unnecessary test code for Julia versions below v1.10. đŸ¤– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- test/clock.jl | 36 ----------------------------------- test/direct.jl | 15 --------------- test/input_output_handling.jl | 2 -- 3 files changed, 53 deletions(-) diff --git a/test/clock.jl b/test/clock.jl index 446b0ffb0d..165c5be968 100644 --- a/test/clock.jl +++ b/test/clock.jl @@ -298,42 +298,6 @@ eqs = [yd ~ Sample(dt)(y) ss = mtkcompile(cl) ss_nosplit = mtkcompile(cl; split = false) - prob = ODEProblem(ss, [x => 0.0, kp => 1.0], (0.0, 1.0)) - prob_nosplit = ODEProblem(ss_nosplit, [x => 0.0, kp => 1.0], (0.0, 1.0)) - sol = solve(prob, Tsit5(), kwargshandle = KeywordArgSilent) - sol_nosplit = solve(prob_nosplit, Tsit5(), kwargshandle = KeywordArgSilent) - - function foo!(dx, x, p, t) - kp, ud1, ud2 = p - dx[1] = -x[1] + ud1 + ud2 - end - - function affect1!(integrator) - kp = integrator.p[1] - y = integrator.u[1] - r = 1.0 - ud1 = kp * (r - y) - integrator.p[2] = ud1 - nothing - end - function affect2!(integrator) - kp = integrator.p[1] - y = integrator.u[1] - r = 1.0 - ud2 = kp * (r - y) - integrator.p[3] = ud2 - nothing - end - cb1 = PeriodicCallback(affect1!, dt; final_affect = true, initial_affect = true) - cb2 = PeriodicCallback(affect2!, dt2; final_affect = true, initial_affect = true) - cb = CallbackSet(cb1, cb2) - # kp ud1 ud2 - prob = ODEProblem(foo!, [0.0], (0.0, 1.0), [1.0, 1.0, 1.0], callback = cb) - sol2 = solve(prob, Tsit5()) - - @test sol.u≈sol2.u atol=1e-6 - @test sol_nosplit.u≈sol2.u atol=1e-6 - ## @info "Testing hybrid system with components" using ModelingToolkitStandardLibrary.Blocks diff --git a/test/direct.jl b/test/direct.jl index 5f52a54fea..0d49afb3e6 100644 --- a/test/direct.jl +++ b/test/direct.jl @@ -240,21 +240,6 @@ kwargs = (; name = 3) @test cool_name[1] == (42,) @test collect(cool_name[2]) == [:name => 3] -name = 3 -@named cool_name = foo(42; name) -@test cool_name[1] == (42,) -@test collect(cool_name[2]) == [:name => name] -@named cool_name = foo(; name) -@test collect(cool_name) == [:name => name] - -ff = 3 -@named cool_name = foo(42; ff) -@test cool_name[1] == (42,) -@test collect(cool_name[2]) == [pp; :ff => ff] - -@named cool_name = foo(; ff) -@test collect(cool_name) == [pp; :ff => ff] - foo(i; name) = (; i, name) @named goo[1:3] = foo(10) @test isequal(goo, [(i = 10, name = Symbol(:goo_, i)) for i in 1:3]) diff --git a/test/input_output_handling.jl b/test/input_output_handling.jl index 54fdbfc1b4..5e3fa92cdc 100644 --- a/test/input_output_handling.jl +++ b/test/input_output_handling.jl @@ -8,8 +8,6 @@ using ModelingToolkit: t_nounits as t, D_nounits as D eqs = [D(xx) ~ some_input] @named model = System(eqs, t) @test_throws ExtraVariablesSystemException mtkcompile(model) -err = "In particular, the unset input(s) are:\n some_input(t)" -@test_throws err mtkcompile(model) # Test input handling @variables x(t) u(t) [input = true] v(t)[1:2] [input = true] From 49e23212f8830aab5cb8083edf16876ef8835fab Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 27 Jul 2025 19:40:25 -0400 Subject: [PATCH 3/5] Update input_output_handling.jl --- test/input_output_handling.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/input_output_handling.jl b/test/input_output_handling.jl index 5e3fa92cdc..54fdbfc1b4 100644 --- a/test/input_output_handling.jl +++ b/test/input_output_handling.jl @@ -8,6 +8,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D eqs = [D(xx) ~ some_input] @named model = System(eqs, t) @test_throws ExtraVariablesSystemException mtkcompile(model) +err = "In particular, the unset input(s) are:\n some_input(t)" +@test_throws err mtkcompile(model) # Test input handling @variables x(t) u(t) [input = true] v(t)[1:2] [input = true] From 14cd4f0447a516d2c329d2ce2899397e19cadfbf Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 27 Jul 2025 19:40:58 -0400 Subject: [PATCH 4/5] Update direct.jl --- test/direct.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/direct.jl b/test/direct.jl index 0d49afb3e6..5f52a54fea 100644 --- a/test/direct.jl +++ b/test/direct.jl @@ -240,6 +240,21 @@ kwargs = (; name = 3) @test cool_name[1] == (42,) @test collect(cool_name[2]) == [:name => 3] +name = 3 +@named cool_name = foo(42; name) +@test cool_name[1] == (42,) +@test collect(cool_name[2]) == [:name => name] +@named cool_name = foo(; name) +@test collect(cool_name) == [:name => name] + +ff = 3 +@named cool_name = foo(42; ff) +@test cool_name[1] == (42,) +@test collect(cool_name[2]) == [pp; :ff => ff] + +@named cool_name = foo(; ff) +@test collect(cool_name) == [pp; :ff => ff] + foo(i; name) = (; i, name) @named goo[1:3] = foo(10) @test isequal(goo, [(i = 10, name = Symbol(:goo_, i)) for i in 1:3]) From 390c7cf397f2ae9f691dadced159cca8c8d6120a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 27 Jul 2025 19:41:41 -0400 Subject: [PATCH 5/5] Update clock.jl --- test/clock.jl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/clock.jl b/test/clock.jl index 165c5be968..96815cd1a2 100644 --- a/test/clock.jl +++ b/test/clock.jl @@ -298,6 +298,42 @@ eqs = [yd ~ Sample(dt)(y) ss = mtkcompile(cl) ss_nosplit = mtkcompile(cl; split = false) + prob = ODEProblem(ss, [x => 0.0, kp => 1.0], (0.0, 1.0)) + prob_nosplit = ODEProblem(ss_nosplit, [x => 0.0, kp => 1.0], (0.0, 1.0)) + sol = solve(prob, Tsit5(), kwargshandle = KeywordArgSilent) + sol_nosplit = solve(prob_nosplit, Tsit5(), kwargshandle = KeywordArgSilent) + + function foo!(dx, x, p, t) + kp, ud1, ud2 = p + dx[1] = -x[1] + ud1 + ud2 + end + + function affect1!(integrator) + kp = integrator.p[1] + y = integrator.u[1] + r = 1.0 + ud1 = kp * (r - y) + integrator.p[2] = ud1 + nothing + end + function affect2!(integrator) + kp = integrator.p[1] + y = integrator.u[1] + r = 1.0 + ud2 = kp * (r - y) + integrator.p[3] = ud2 + nothing + end + cb1 = PeriodicCallback(affect1!, dt; final_affect = true, initial_affect = true) + cb2 = PeriodicCallback(affect2!, dt2; final_affect = true, initial_affect = true) + cb = CallbackSet(cb1, cb2) + # kp ud1 ud2 + prob = ODEProblem(foo!, [0.0], (0.0, 1.0), [1.0, 1.0, 1.0], callback = cb) + sol2 = solve(prob, Tsit5()) + + @test sol.u≈sol2.u atol=1e-6 + @test sol_nosplit.u≈sol2.u atol=1e-6 + ## @info "Testing hybrid system with components" using ModelingToolkitStandardLibrary.Blocks