From 2b24c04f5fb13cd648be4fe19a57a408f6c0cecd Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Thu, 11 Sep 2025 13:36:18 +0000 Subject: [PATCH 1/4] chore: copy parameters from sys --- src/parameters.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parameters.jl b/src/parameters.jl index 93c74e36a9..d8ff1bf1be 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -172,7 +172,7 @@ function subset_tunables(sys, new_tunables) Note that array parameters can only be set as tunable or non-tunable, not partially tunable. They should be specified in the un-scalarized form. """)) end - cur_ps = get_ps(sys) + cur_ps = copy(get_ps(sys)) const_ps = toconstant.(diff_params) for (idx, p) in enumerate(cur_ps) From fc62ff1da128eaeae6fb93574c2c2345dc6d1d2f Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Wed, 17 Sep 2025 12:25:13 +0000 Subject: [PATCH 2/4] test: check length of original system tunables --- test/parameter_dependencies.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/parameter_dependencies.jl b/test/parameter_dependencies.jl index 7316a59bc4..e5c325c182 100644 --- a/test/parameter_dependencies.jl +++ b/test/parameter_dependencies.jl @@ -198,6 +198,8 @@ end @test_throws ArgumentError ModelingToolkit.subset_tunables(sys_incomplete, new_tunables) sys_nonsplit = mtkcompile(pendulum_sys; split = false) @test_throws ArgumentError ModelingToolkit.subset_tunables(sys_nonsplit, new_tunables) + + @test length(ModelingToolkit.tunable_parameters(sys)) == 3 end struct CallableFoo From a4c6ad540cdeeebad8eb4f83de95b8ad9eae8eb7 Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Thu, 18 Sep 2025 13:22:43 +0000 Subject: [PATCH 3/4] test: improve test checking --- test/parameter_dependencies.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parameter_dependencies.jl b/test/parameter_dependencies.jl index e5c325c182..99ad76f6c3 100644 --- a/test/parameter_dependencies.jl +++ b/test/parameter_dependencies.jl @@ -184,6 +184,7 @@ end sys = mtkcompile(pendulum_sys) new_tunables = [L, b] + old_tunables = copy(ModelingToolkit.tunable_parameters(sys, ModelingToolkit.parameters(sys))) sys2 = ModelingToolkit.subset_tunables(sys, new_tunables) sys2_tunables = ModelingToolkit.tunable_parameters(sys2, ModelingToolkit.parameters(sys2)) @test length(sys2_tunables) == 2 @@ -199,7 +200,7 @@ end sys_nonsplit = mtkcompile(pendulum_sys; split = false) @test_throws ArgumentError ModelingToolkit.subset_tunables(sys_nonsplit, new_tunables) - @test length(ModelingToolkit.tunable_parameters(sys)) == 3 + @test length(ModelingToolkit.tunable_parameters(sys)) == length(old_tunables) end struct CallableFoo From ac5ec9c46b75efb30b5e480a2688701557127223 Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Thu, 18 Sep 2025 15:33:37 +0000 Subject: [PATCH 4/4] test: typo --- test/parameter_dependencies.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parameter_dependencies.jl b/test/parameter_dependencies.jl index 99ad76f6c3..c39bb274e6 100644 --- a/test/parameter_dependencies.jl +++ b/test/parameter_dependencies.jl @@ -200,7 +200,7 @@ end sys_nonsplit = mtkcompile(pendulum_sys; split = false) @test_throws ArgumentError ModelingToolkit.subset_tunables(sys_nonsplit, new_tunables) - @test length(ModelingToolkit.tunable_parameters(sys)) == length(old_tunables) + @test length(ModelingToolkit.tunable_parameters(sys, ModelingToolkit.parameters(sys))) == length(old_tunables) end struct CallableFoo