Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Feb 26, 2024
1 parent 2f027fa commit 5601282
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ tsaves(model::Model)::Vector{Float64} = model.integrator.sol.t

"Get all saved times as a Vector{DateTime}"
function datetimes(model::Model)::Vector{DateTime}
return datetime_since.(tstops(model), model.config.starttime)
return datetime_since.(tsaves(model), model.config.starttime)
end

function Base.show(io::IO, model::Model)
(; config, integrator) = model
t = datetime_since(integrator.t, config.starttime)
nsaved = length(tstops(model))
nsaved = length(tsaves(model))

Check warning on line 168 in core/src/model.jl

View check run for this annotation

Codecov / codecov/patch

core/src/model.jl#L168

Added line #L168 was not covered by tests
println(io, "Model(ts: $nsaved, t: $t)")
end

Expand Down
12 changes: 6 additions & 6 deletions core/test/equations_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@test successful_retcode(model)
(; p) = model.integrator

t = Ribasim.tstops(model)
t = Ribasim.tsaves(model)
storage = Ribasim.get_storages_and_levels(model).storage[1, :]
A = p.basin.area[1][2] # needs to be constant
u0 = A * 10.0
Expand Down Expand Up @@ -57,7 +57,7 @@ end
@test successful_retcode(model)
p = model.integrator.p

t = Ribasim.tstops(model)
t = Ribasim.tsaves(model)
storage = Ribasim.get_storages_and_levels(model).storage[1, :]
basin_area = p.basin.area[1][2]
storage_min = 50.005
Expand Down Expand Up @@ -93,7 +93,7 @@ end
p = model.integrator.p
(; manning_resistance) = p

t = Ribasim.tstops(model)
t = Ribasim.tsaves(model)
storage_both = Ribasim.get_storages_and_levels(model).storage
storage = storage_both[1, :]
storage_min = 50.005
Expand Down Expand Up @@ -131,7 +131,7 @@ end
(; basin, pid_control) = p

storage = Ribasim.get_storages_and_levels(model).storage[:]
t = Ribasim.tstops(model)
t = Ribasim.tsaves(model)
SP = pid_control.target[1](0)
K_p, K_i, K_d = pid_control.pid_params[1](0)

Expand Down Expand Up @@ -168,7 +168,7 @@ end
@testitem "MiscellaneousNodes" begin
using PreallocationTools: get_tmp
using SciMLBase: successful_retcode
using Ribasim: tstops, get_storages_and_levels
using Ribasim: tsaves, get_storages_and_levels

toml_path = normpath(@__DIR__, "../../generated_testmodels/misc_nodes/ribasim.toml")
@test ispath(toml_path)
Expand All @@ -186,7 +186,7 @@ end
frac = fractional_flow.fraction[1]

storage_both = get_storages_and_levels(model).storage
t = tstops(model)
t = tsaves(model)
tspan = model.integrator.sol.prob.tspan
@test t range(tspan...; step = config.solver.saveat)
@test storage_both[1, :] @. storage_both[1, 1] + t * (frac * q_boundary - q_pump)
Expand Down

0 comments on commit 5601282

Please sign in to comment.