Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Oct 8, 2023
1 parent aa1839c commit 325fb78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 6 additions & 14 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -737,28 +737,20 @@ let
u0map = [A => 1.0]
pmap = (k1 => 1.0, k2 => 1)
tspan = (0.0, 1.0)
prob = ODEProblem(sys, u0map, tspan, pmap; tofloat = false)
@test prob.p == ([1], [1.0]) #Tuple([(Dict(pmap))[k] for k in values(parameters(sys))])
prob = ODEProblem(sys, u0map, tspan, pmap; tofloat = true)
@test prob.p == [1.0, 1.0]

prob = ODEProblem(sys, u0map, tspan, pmap)
@test prob.p isa Vector{Float64}
@test prob.p isa Tuple{Vector{Float64}, Vector{Int}}
@test prob.p == ([1.0], [1])

pmap = [k1 => 1, k2 => 1]
tspan = (0.0, 1.0)
prob = ODEProblem(sys, u0map, tspan, pmap)
prob = ODEProblem(sys, u0map, tspan, pmap; tofloat = true)
@test eltype(prob.p) === Float64

prob = ODEProblem(sys, u0map, tspan, pmap; tofloat = false)
@test eltype(prob.p) === Int

prob = ODEProblem(sys, u0map, tspan, pmap)
@test prob.p isa Vector{Float64}

# No longer supported, Tuple used instead
# pmap = Pair{Any, Union{Int, Float64}}[k1 => 1, k2 => 1.0]
# tspan = (0.0, 1.0)
# prob = ODEProblem(sys, u0map, tspan, pmap, use_union = true)
# @test eltype(prob.p) === Union{Float64, Int}
@test eltype(prob.p) === Int
end

let
Expand Down
2 changes: 1 addition & 1 deletion test/state_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let
D(supply_pipe.fluid_port_a.m) => 0.0]
prob1 = ODEProblem(sys, u0, (0.0, 10.0), [])
prob2 = ODAEProblem(sys, u0, (0.0, 10.0), [])
prob3 = DAEProblem(sys, D.(states(sys)) .=> 0.0, u0, (0.0, 10.0), [])
prob3 = DAEProblem(sys, D.(states(sys)) .=> 0.0, u0, (0.0, 10.0), [], tofloat = true)
@test solve(prob1, FBDF()).retcode == ReturnCode.Success
#@test solve(prob2, FBDF()).retcode == ReturnCode.Success
@test solve(prob3, DFBDF()).retcode == ReturnCode.Success
Expand Down

0 comments on commit 325fb78

Please sign in to comment.