Skip to content
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/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/parameter_dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -198,6 +199,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, ModelingToolkit.parameters(sys))) == length(old_tunables)
end

struct CallableFoo
Expand Down
Loading