Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 529: Create null Latent model #530

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion EpiAware/src/EpiLatentModels/EpiLatentModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Turing, Distributions, DocStringExtensions, LinearAlgebra, SparseArrays,
OrdinaryDiffEq

#Export models
export FixedIntercept, Intercept, RandomWalk, AR, HierarchicalNormal
export FixedIntercept, Intercept, RandomWalk, AR, HierarchicalNormal, Null

#Export ODE definitions
export SIRParams, SEIRParams
Expand All @@ -38,6 +38,7 @@ include("models/Intercept.jl")
include("models/RandomWalk.jl")
include("models/AR.jl")
include("models/HierarchicalNormal.jl")
include("models/Null.jl")
include("odemodels/SIRParams.jl")
include("odemodels/SEIRParams.jl")
include("modifiers/DiffLatentModel.jl")
Expand Down
24 changes: 24 additions & 0 deletions EpiAware/src/EpiLatentModels/models/Null.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@doc raw"
A null model struct. This struct is used to indicate that no latent variables are to be generated.
"
struct Null <: AbstractTuringLatentModel end

@doc raw"
Generates `nothing` as latent variables for the given `latent_model` of type `Null`.

# Example
```jldoctest
using EpiAware
null = Null()
null_mdl = generate_latent(null, 10)
isnothing(null_mdl())

# Output

true

```
"
@model function EpiAwareBase.generate_latent(latent_model::Null, n)
return nothing
end
8 changes: 8 additions & 0 deletions EpiAware/test/EpiLatentModels/models/Null.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@testitem "Null Model Tests" begin
# Test that Null can be instantiated
@test Null() isa Null

# Test that generate_latent returns nothing
null = Null()
@test isnothing(generate_latent(null, 10)())
end
Loading