Skip to content

Commit

Permalink
Issue 529: Create null Latent model (#530)
Browse files Browse the repository at this point in the history
* Null Latent model

* Null Latent model

* fix doctest
  • Loading branch information
SamuelBrand1 authored Nov 20, 2024
1 parent 7fd98c8 commit ae73647
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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

0 comments on commit ae73647

Please sign in to comment.