Skip to content

Commit

Permalink
post processing functions return Vector{Float64} (#368)
Browse files Browse the repository at this point in the history
* bug fix when passing dt

* remove double collect
  • Loading branch information
m-bossart authored Mar 29, 2024
1 parent 787ebcf commit 6eda891
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/base/simulation_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ function _post_proc_state_series(solution, ix::Int, dt::Nothing)
end

function _post_proc_state_series(solution, ix::Int, dt::Float64)
ts = range(0; stop = solution.t[end], step = dt)
state = solution(collect(ts); idxs = ix)
return ts, state
ts = collect(range(0; stop = solution.t[end], step = dt))
state = solution(ts; idxs = ix)
return ts, state.u
end

function _post_proc_state_series(solution, ix::Int, dt::Vector{Float64})
state = solution(dt; idxs = ix)
return dt, state
return dt, state.u
end

"""
Expand Down
4 changes: 4 additions & 0 deletions test/test_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,14 @@ end
series = get_state_series(results, ("generator-102-1", ); dt = 0.01)
t = series[1]
δ = series[2]
@test typeof(t) == Vector{Float64}
@test typeof(δ) == Vector{Float64}
@test t[2] - t[1] == 0.01
series = get_state_series(results, ("generator-102-1", ); dt = [0.02, 0.05])
t = series[1]
δ = series[2]
@test typeof(t) == Vector{Float64}
@test typeof(δ) == Vector{Float64}
@test t[1] == 0.02
finally
@info("removing test files")
Expand Down

0 comments on commit 6eda891

Please sign in to comment.