Skip to content

Commit

Permalink
Merge pull request #3143 from AayushSabharwal/as/linfun-dep-p
Browse files Browse the repository at this point in the history
fix: fix `linearization_function` not handling dependent parameter mapping
  • Loading branch information
ChrisRackauckas authored Oct 24, 2024
2 parents 8f2a9e4 + d11d98d commit 9b439b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ function linearization_function(sys::AbstractSystem, inputs,
newps = deepcopy(sys_ps)
for (k, v) in p
if is_parameter(sys, k)
v = fixpoint_sub(v, p)
setp(sys, k)(newps, v)
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/downstream/linearize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ matrices = linfun([1.0], Dict(p => 3.0), 1.0)
# this would be 1 if the parameter value isn't respected
@test matrices.f_u[] == 3.0

@testset "linearization_function handles dependent values" begin
@parameters q
matrices = @test_nowarn linfun([1.0], Dict(p => 3q, q => 1.0), 1.0)
@test matrices.f_u[] == 3.0
end

@testset "Issue #2941" begin
@variables x(t) y(t)
@parameters p
Expand Down

0 comments on commit 9b439b7

Please sign in to comment.