Skip to content

Commit

Permalink
switch trans_fuunction to transform (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs authored Dec 14, 2024
1 parent d3fa45f commit ab73d9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ The `TransformLatentModel` struct represents a latent model that applies a trans
## Constructors
- `TransformLatentModel(model, trans_function)`: Constructs a `TransformLatentModel` instance with the specified latent model and transformation function.
- `TransformLatentModel(; model, trans_function)`: Constructs a `TransformLatentModel` instance with the specified latent model and transformation function using named arguments.
- `TransformLatentModel(model, transform)`: Constructs a `TransformLatentModel` instance with the specified latent model and transformation function.
- `TransformLatentModel(; model, transform)`: Constructs a `TransformLatentModel` instance with the specified latent model and transformation function using named arguments.
## Example
Expand All @@ -20,7 +20,7 @@ trans_model()
"The latent model to transform."
model::M
"The transformation function."
trans_function::F
transform::F
end

"""
Expand All @@ -38,6 +38,6 @@ Generate latent variables using the specified `TransformLatentModel`.
"""
@model function EpiAwareBase.generate_latent(model::TransformLatentModel, n)
@submodel untransformed = generate_latent(model.model, n)
latent = model.trans_function(untransformed)
latent = model.transform(untransformed)
return latent
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
trans = TransformLatentModel(Intercept(Normal(2, 0.2)), x -> x .|> exp)
@test typeof(trans) <: AbstractTuringLatentModel
@test trans.model == Intercept(Normal(2, 0.2))
@test trans.trans_function([1, 2, 3]) == [exp(1), exp(2), exp(3)]
@test trans.transform([1, 2, 3]) == [exp(1), exp(2), exp(3)]
end

@testitem "TransformLatentModel generate_latent method" begin
Expand Down

0 comments on commit ab73d9e

Please sign in to comment.