Skip to content

Commit

Permalink
Add tests for instantiate and general fallback for NodeType
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterwln committed Sep 25, 2024
1 parent c8181d9 commit 73d1304
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/model/graphppl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function GraphPPL.NodeType(backend::ReactiveMPGraphPPLBackend{Static.True}, some
end
function GraphPPL.NodeType(backend::ReactiveMPGraphPPLBackend{Static.True}, ::ReactiveMP.UndefinedNodeFunctionalForm, something::F) where {F}
# Fallback to the default behaviour if the node is not predefined
return GraphPPL.NodeType(ReactiveMPGraphPPLBackend(Static.False), something)
return GraphPPL.NodeType(ReactiveMPGraphPPLBackend(Static.False()), something)
end
function GraphPPL.NodeType(backend::ReactiveMPGraphPPLBackend{Static.True}, ::ReactiveMP.PredefinedNodeFunctionalForm, something::F) where {F}
# Fallback to the default behaviour if the node is not predefined
Expand Down
12 changes: 12 additions & 0 deletions test/model/graphppl_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,15 @@ end
@test_throws ErrorException GraphPPL.default_parametrization(backend, GraphPPL.Atomic(), f, (1,))
@test_throws ErrorException GraphPPL.default_parametrization(backend, GraphPPL.Atomic(), f, (1, 2, 3))
end

@testitem "Backend Tests" begin
import GraphPPL
import Static
import RxInfer: ReactiveMPGraphPPLBackend

@test GraphPPL.instantiate(ReactiveMPGraphPPLBackend{Static.True}) == ReactiveMPGraphPPLBackend(Static.True())
@test GraphPPL.instantiate(ReactiveMPGraphPPLBackend{Static.False}) == ReactiveMPGraphPPLBackend(Static.False())
@test GraphPPL.instantiate(ReactiveMPGraphPPLBackend) == ReactiveMPGraphPPLBackend(Static.False())

@test GraphPPL.NodeType(ReactiveMPGraphPPLBackend(Static.True()), ReactiveMP.UndefinedNodeFunctionalForm(), sum) == GraphPPL.Atomic()
end

0 comments on commit 73d1304

Please sign in to comment.