Skip to content

Commit

Permalink
Issue 563: Change lookback to 90 time steps (#564)
Browse files Browse the repository at this point in the history
* change lookback to 90 time steps

* fix unit tests
  • Loading branch information
SamuelBrand1 authored Dec 19, 2024
1 parent 7dde0e9 commit 0d4095e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pipeline/src/constructors/make_default_params.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function make_default_params(pipeline::AbstractEpiAwarePipeline)
α_delay = 4.0
θ_delay = 5.0 / 4.0
lookahead = 21
lookback = 35
lookback = 90
stride = 7
return Dict(
"Rt" => Rt,
Expand Down
4 changes: 2 additions & 2 deletions pipeline/src/constructors/make_tspan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Constructs a time span for performing inference on a case data time series. This
- `T::Union{Integer,Nothing} = nothing`: The `stop` point at which to construct
the time span. If `nothing`, the time span will be constructed using the
length of the Rt vector for `pipeline`.
- `lookback = 35`: The number of days to look back from the specified time point.
- `lookback`: The number of days to look back from the specified time point.
# Returns
A tuple `(start, stop)` representing the start and stop indices of the time span.
Expand All @@ -16,7 +16,7 @@ A tuple `(start, stop)` representing the start and stop indices of the time span
"""
function make_tspan(pipeline::AbstractEpiAwarePipeline;
T::Union{Integer, Nothing} = nothing, lookback = 35)
T::Union{Integer, Nothing} = nothing, lookback)
N = size(make_Rt(pipeline), 1)
_T = isnothing(T) ? N : T
return (max(1, _T - lookback), min(N, _T))
Expand Down
2 changes: 2 additions & 0 deletions pipeline/src/infer/InferenceConfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ to make inference on and model configuration.
function create_inference_results(config, epiprob)
#Return the sampled infections and observations
idxs = config.tspan[1]:config.tspan[2]
#Subselect the case data to the time span
y_t = ismissing(config.case_data) ? missing :
Vector{Union{Missing, Int64}}(config.case_data[idxs])
#Run inference once
inference_results = apply_method(epiprob,
config.epimethod,
(y_t = y_t,)
Expand Down
4 changes: 2 additions & 2 deletions pipeline/test/constructors/test_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
@testset "default_tspan: returns an Tuple{Integer, Integer}" begin
pipeline = EpiAwareExamplePipeline()

tspan = make_tspan(pipeline)
tspan = make_tspan(pipeline; lookback = 90)
@test tspan isa Tuple{Integer, Integer}
end

Expand Down Expand Up @@ -138,7 +138,7 @@ end
"α_delay" => 4.0,
"θ_delay" => 5.0 / 4.0,
"lookahead" => 21,
"lookback" => 35,
"lookback" => 90,
"stride" => 7
)

Expand Down

0 comments on commit 0d4095e

Please sign in to comment.