-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example mode and unit tests for pipeline functions. (#295)
* unit tests for pipeline functions. * reformat * Move dispatch on example mode to the config list constructors with additional unit testing * reformat * Add _selector methods to dispatch different pipeline number of scenarios
- Loading branch information
1 parent
2b6ef61
commit 18f8aec
Showing
7 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Internal method for selecting from a list of items based on the pipeline type. | ||
Default is to return the list as is. | ||
""" | ||
function _selector(list, pipeline::AbstractEpiAwarePipeline) | ||
return list | ||
end | ||
|
||
""" | ||
Internal method for selecting from a list of items based on the pipeline type. | ||
Example/test mode is to return a randomly selected item from the list. | ||
""" | ||
function _selector(list, pipeline::EpiAwareExamplePipeline) | ||
return [rand(list)] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@testset "do_truthdata tests" begin | ||
using EpiAwarePipeline, Dagger | ||
pipeline = EpiAwareExamplePipeline() | ||
truthdata_dg_task = do_truthdata(pipeline) | ||
truthdata = fetch.(truthdata_dg_task) | ||
|
||
@test length(truthdata) == 1 | ||
@test all([data["y_t"] isa Vector{Union{Missing, Real}} for data in truthdata]) | ||
end | ||
|
||
@testset "do_inference tests" begin | ||
using EpiAwarePipeline | ||
pipeline = EpiAwareExamplePipeline() | ||
|
||
function make_inference() | ||
truthdata = do_truthdata(pipeline) | ||
do_inference(truthdata[1:1], pipeline) | ||
end | ||
|
||
inference_results_tsk = make_inference() | ||
inference_results = fetch.(inference_results_tsk) | ||
@test length(inference_results) == 1 | ||
@test all([result["inference_results"] isa EpiAwareObservables | ||
for result in inference_results]) | ||
end | ||
|
||
@testset "do_pipeline test: just run" begin | ||
using EpiAwarePipeline | ||
pipeline = EpiAwareExamplePipeline() | ||
res = do_pipeline(pipeline) | ||
@test isnothing(res) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters