Commit 37f61f46 authored by Bentriou Mahmoud's avatar Bentriou Mahmoud
Browse files

Useful brackets indexing for trajectories + test.

parent f95d6529
......@@ -35,10 +35,9 @@ function getindex(σ::AbstractTrajectory, var::String)
end
end
# Get i-th state [i]
getindex(σ::AbstractTrajectory, idx::Int) = get_state(σ, i)
getindex(σ::AbstractTrajectory, idx::Int) = get_state(σ, idx)
# Get i-th value of var ["I", idx]
function getindex(σ::AbstractTrajectory, var_idx::Tuple{String,Int})
var, idx = var_idx[1], var_idx[2]
function getindex(σ::AbstractTrajectory, var::String, idx::Int)
if var == "times"
return σ.times[idx]
elseif var == "transitions"
......
......@@ -10,5 +10,6 @@ using Test
@test include("unit/simulate_er.jl")
@test include("unit/change_obs_var_sir.jl")
@test include("unit/change_obs_var_sir_2.jl")
@test include("unit/getindex_access_trajectory.jl")
end
using MarkovProcesses
load_model("SIR")
σ = simulate(SIR)
σ["I"]
σ["I",2]
σ[3]
return true
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment